@lombard.finance/sdk 5.0.2 → 5.0.4
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/CHANGELOG.md +20 -0
- package/dist/api-functions/storeNetworkFeeSignature/storeNetworkFeeSignature.d.ts +13 -0
- package/dist/api-functions/storeNetworkFeeSignature/storeNetworkFeeSignature.d.ts.map +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.js +12 -11
- package/dist/api.js.map +1 -1
- package/dist/bridge.cjs +1 -1
- package/dist/bridge.js +1 -1
- package/dist/btc.cjs +1 -1
- package/dist/btc.js +2 -2
- package/dist/chains/btc/actions/stake/config/evm.d.ts.map +1 -1
- package/dist/chunks/{BtcActions-CJY0V8JC.js → BtcActions-D7HekjRg.js} +236 -217
- package/dist/chunks/{BtcActions-CJY0V8JC.js.map → BtcActions-D7HekjRg.js.map} +1 -1
- package/dist/chunks/BtcActions-lp4P72ln.cjs +2 -0
- package/dist/chunks/{BtcActions-B9KwzjIG.cjs.map → BtcActions-lp4P72ln.cjs.map} +1 -1
- package/dist/chunks/EvmActions-CynfSVFq.cjs +7 -0
- package/dist/chunks/{EvmActions-DBAcQeMr.cjs.map → EvmActions-CynfSVFq.cjs.map} +1 -1
- package/dist/chunks/{EvmActions-BGlhbADC.js → EvmActions-nbR8cSa4.js} +38 -37
- package/dist/chunks/{EvmActions-BGlhbADC.js.map → EvmActions-nbR8cSa4.js.map} +1 -1
- package/dist/chunks/{ReferralsClient-o-3AUm7s.cjs → ReferralsClient-B65Nsk21.cjs} +2 -2
- package/dist/chunks/{ReferralsClient-o-3AUm7s.cjs.map → ReferralsClient-B65Nsk21.cjs.map} +1 -1
- package/dist/chunks/{ReferralsClient-BRa26dYS.js → ReferralsClient-BNwB6wO4.js} +2 -2
- package/dist/chunks/{ReferralsClient-BRa26dYS.js.map → ReferralsClient-BNwB6wO4.js.map} +1 -1
- package/dist/chunks/{approveLBTC-BBl3KcT2.cjs → approveLBTC-B1QepkpF.cjs} +2 -2
- package/dist/chunks/{approveLBTC-BBl3KcT2.cjs.map → approveLBTC-B1QepkpF.cjs.map} +1 -1
- package/dist/chunks/{approveLBTC-DnCt6ZZF.js → approveLBTC-BFhW5cPX.js} +2 -2
- package/dist/chunks/{approveLBTC-DnCt6ZZF.js.map → approveLBTC-BFhW5cPX.js.map} +1 -1
- package/dist/chunks/{bridge-DZp5x4Yb.cjs → bridge-CQmXrRKS.cjs} +2 -2
- package/dist/chunks/{bridge-DZp5x4Yb.cjs.map → bridge-CQmXrRKS.cjs.map} +1 -1
- package/dist/chunks/{bridge-DV4fOcHe.js → bridge-DnDIoRdh.js} +3 -3
- package/dist/chunks/{bridge-DV4fOcHe.js.map → bridge-DnDIoRdh.js.map} +1 -1
- package/dist/chunks/depositStatus-DUXMloTa.cjs +2 -0
- package/dist/chunks/{depositStatus-B9P1YXEU.cjs.map → depositStatus-DUXMloTa.cjs.map} +1 -1
- package/dist/chunks/{depositStatus-Cgd_GDUt.js → depositStatus-hmXphYhu.js} +4 -4
- package/dist/chunks/{depositStatus-Cgd_GDUt.js.map → depositStatus-hmXphYhu.js.map} +1 -1
- package/dist/chunks/{events-od93kR_o.js → events-BP_Ahnsm.js} +47 -45
- package/dist/chunks/events-BP_Ahnsm.js.map +1 -0
- package/dist/chunks/events-DY2qn8Q0.cjs +2 -0
- package/dist/chunks/events-DY2qn8Q0.cjs.map +1 -0
- package/dist/chunks/{get-vault-tvl-B6rSrGi_.js → get-vault-tvl-CweOpdGy.js} +58 -55
- package/dist/chunks/get-vault-tvl-CweOpdGy.js.map +1 -0
- package/dist/chunks/get-vault-tvl-vH_D4tu0.cjs +2 -0
- package/dist/chunks/get-vault-tvl-vH_D4tu0.cjs.map +1 -0
- package/dist/chunks/{get-vault-withdrawals-W5CgNbqE.js → get-vault-withdrawals-BayGky8y.js} +44 -38
- package/dist/chunks/get-vault-withdrawals-BayGky8y.js.map +1 -0
- package/dist/chunks/get-vault-withdrawals-GHCAh3wp.cjs +2 -0
- package/dist/chunks/get-vault-withdrawals-GHCAh3wp.cjs.map +1 -0
- package/dist/chunks/getNetworkFeeSignature-DqKLslZc.cjs +2 -0
- package/dist/chunks/getNetworkFeeSignature-DqKLslZc.cjs.map +1 -0
- package/dist/chunks/getNetworkFeeSignature-FuDJWrMC.js +38 -0
- package/dist/chunks/getNetworkFeeSignature-FuDJWrMC.js.map +1 -0
- package/dist/chunks/{getUserStakeAndBakeSignature-BRhWFYyY.js → getUserStakeAndBakeSignature-CQsvL79O.js} +2 -2
- package/dist/chunks/{getUserStakeAndBakeSignature-BRhWFYyY.js.map → getUserStakeAndBakeSignature-CQsvL79O.js.map} +1 -1
- package/dist/chunks/{getUserStakeAndBakeSignature-VlC_GHmz.cjs → getUserStakeAndBakeSignature-Cwwx89pR.cjs} +2 -2
- package/dist/chunks/{getUserStakeAndBakeSignature-VlC_GHmz.cjs.map → getUserStakeAndBakeSignature-Cwwx89pR.cjs.map} +1 -1
- package/dist/chunks/statusConstants-D4DN05kK.cjs +2 -0
- package/dist/chunks/{statusConstants-CP33VFvI.cjs.map → statusConstants-D4DN05kK.cjs.map} +1 -1
- package/dist/chunks/{statusConstants-sPFaTvG2.js → statusConstants-DLrd03gT.js} +3 -3
- package/dist/chunks/{statusConstants-sPFaTvG2.js.map → statusConstants-DLrd03gT.js.map} +1 -1
- package/dist/chunks/storeNetworkFeeSignature-BaG3AU8U.cjs +2 -0
- package/dist/chunks/storeNetworkFeeSignature-BaG3AU8U.cjs.map +1 -0
- package/dist/chunks/storeNetworkFeeSignature-sCt4_nHr.js +52 -0
- package/dist/chunks/storeNetworkFeeSignature-sCt4_nHr.js.map +1 -0
- package/dist/chunks/{tokens-Btl3GXbc.js → tokens-BUrC15ra.js} +5 -5
- package/dist/chunks/{tokens-Btl3GXbc.js.map → tokens-BUrC15ra.js.map} +1 -1
- package/dist/chunks/{tokens-DEYY7W7O.cjs → tokens-C5rzCTTM.cjs} +2 -2
- package/dist/chunks/{tokens-DEYY7W7O.cjs.map → tokens-C5rzCTTM.cjs.map} +1 -1
- package/dist/chunks/{unwrapBtceToLbtcv-Cu9KedO1.js → unwrapBtceToLbtcv-BL5bF9y2.js} +3 -3
- package/dist/chunks/{unwrapBtceToLbtcv-Cu9KedO1.js.map → unwrapBtceToLbtcv-BL5bF9y2.js.map} +1 -1
- package/dist/chunks/{unwrapBtceToLbtcv-BlRUepkS.cjs → unwrapBtceToLbtcv-Chc_QObp.cjs} +2 -2
- package/dist/chunks/{unwrapBtceToLbtcv-BlRUepkS.cjs.map → unwrapBtceToLbtcv-Chc_QObp.cjs.map} +1 -1
- package/dist/chunks/{withdrawEarn-D835YnBD.js → withdrawEarn-BM_JOe4k.js} +2 -2
- package/dist/chunks/{withdrawEarn-D835YnBD.js.map → withdrawEarn-BM_JOe4k.js.map} +1 -1
- package/dist/chunks/{withdrawEarn-CVQYjOoY.cjs → withdrawEarn-CXfCmXJl.cjs} +2 -2
- package/dist/chunks/{withdrawEarn-CVQYjOoY.cjs.map → withdrawEarn-CXfCmXJl.cjs.map} +1 -1
- package/dist/client/ApiNamespace.d.ts.map +1 -1
- package/dist/common/chains.d.ts +3 -0
- package/dist/common/chains.d.ts.map +1 -1
- package/dist/contracts.cjs +1 -1
- package/dist/contracts.js +3 -3
- package/dist/core.cjs +1 -1
- package/dist/core.js +6 -6
- package/dist/evm.cjs +1 -1
- package/dist/evm.js +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +264 -263
- package/dist/tokens/tokens.d.ts +1 -1
- package/dist/tokens/tokens.d.ts.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/vaults/lib/ops/get-vault-deposits.d.ts +3 -2
- package/dist/vaults/lib/ops/get-vault-deposits.d.ts.map +1 -1
- package/dist/vaults/lib/ops/get-vault-withdrawals.d.ts +3 -2
- package/dist/vaults/lib/ops/get-vault-withdrawals.d.ts.map +1 -1
- package/dist/vaults.cjs +1 -1
- package/dist/vaults.js +3 -3
- package/package.json +1 -1
- package/dist/chunks/BtcActions-B9KwzjIG.cjs +0 -2
- package/dist/chunks/EvmActions-DBAcQeMr.cjs +0 -7
- package/dist/chunks/constants-D1FnS2Z8.js +0 -6
- package/dist/chunks/constants-D1FnS2Z8.js.map +0 -1
- package/dist/chunks/constants-ueShGH9R.cjs +0 -2
- package/dist/chunks/constants-ueShGH9R.cjs.map +0 -1
- package/dist/chunks/depositStatus-B9P1YXEU.cjs +0 -2
- package/dist/chunks/events-DBUF2B7z.cjs +0 -2
- package/dist/chunks/events-DBUF2B7z.cjs.map +0 -1
- package/dist/chunks/events-od93kR_o.js.map +0 -1
- package/dist/chunks/get-vault-tvl-B6rSrGi_.js.map +0 -1
- package/dist/chunks/get-vault-tvl-dvEPPxvT.cjs +0 -2
- package/dist/chunks/get-vault-tvl-dvEPPxvT.cjs.map +0 -1
- package/dist/chunks/get-vault-withdrawals-Cgx7VsM1.cjs +0 -2
- package/dist/chunks/get-vault-withdrawals-Cgx7VsM1.cjs.map +0 -1
- package/dist/chunks/get-vault-withdrawals-W5CgNbqE.js.map +0 -1
- package/dist/chunks/statusConstants-CP33VFvI.cjs +0 -2
- package/dist/chunks/storeNetworkFeeSignature-CY_Z-Wtn.js +0 -65
- package/dist/chunks/storeNetworkFeeSignature-CY_Z-Wtn.js.map +0 -1
- package/dist/chunks/storeNetworkFeeSignature-DJgBfZp7.cjs +0 -2
- package/dist/chunks/storeNetworkFeeSignature-DJgBfZp7.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depositStatus-B9P1YXEU.cjs","sources":["../../src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.ts","../../src/api-functions/setReferral/setReferral.ts","../../src/shared/deposits/depositStatus.ts"],"sourcesContent":["import axios from 'axios';\nimport BigNumber from 'bignumber.js';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { getChainNameById } from '../../common/blockchain-identifier';\nimport { ChainId } from '../../common/chains';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\nimport { IEnvParam } from '../../common/parameters';\nimport { toSatoshi } from '../../utils/satoshi';\n\ntype ExchangeRateResponse = {\n amount_out: string;\n};\n\nexport interface IgetLBTCExchangeRateParams extends IEnvParam {\n /**\n * The optional chain id of the asset to get the exchange rate for.\n * Note: Exchange rate it the same for all chains.\n *\n * @default OChainId.ethereum\n */\n chainId?: ChainId;\n /**\n * The amount of the LBTC (in satoshis) that a user would like to exchange to BTC.\n */\n amount?: BigNumber.Value;\n}\n\nexport interface IgetLBTCExchangeRateResponse {\n /**\n * The exchanged amount (in satoshis).\n */\n amountOut: number;\n /**\n * The exchange rate for LBTC/BTC.\n */\n exchangeRate: number;\n /**\n * The minimum amount of BTC eligible for staking (in satoshis).\n */\n minAmount: number;\n}\n\n/**\n * Retrieves the exchange rate for LBTC.\n *\n * @deprecated This API endpoint is deprecated and will be removed in a future version.\n * The exchange rate is now always 1:1 as LBTC is a rebasing token.\n *\n * @param {IgetLBTCExchangeRateParams} parameters - The parameters.\n * @param {BigNumber.Value} parameters.amount - The optional amount to be exchanged.\n * @param {ChainId} parameters.chainId - The optional chain id.\n * @param {Env} parameters.env - The optional environment identifier.\n *\n * @returns {Promise<IgetLBTCExchangeRateResponse>} - The exchange rate.\n */\nexport async function getLBTCExchangeRate({\n env,\n chainId = ChainId.ethereum,\n amount = toSatoshi(1),\n}: IgetLBTCExchangeRateParams): Promise<IgetLBTCExchangeRateResponse> {\n const { baseApiUrl } = getApiConfig(env);\n const chainIdName = getChainNameById(chainId);\n\n const { data } = await axios.get<ExchangeRateResponse>(\n `api/v1/exchange/rate/${chainIdName}`,\n { baseURL: baseApiUrl, params: { amount } },\n );\n\n const amountOut = BigNumber(data.amount_out).toNumber();\n const exchangeRate = BigNumber(amount).dividedBy(data.amount_out).toNumber();\n const minAmount = toSatoshi(MIN_STAKE_AMOUNT_BTC).toNumber();\n\n return { amountOut, exchangeRate, minAmount };\n}\n","import axios from 'axios';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { IEnvParam } from '../../common/parameters';\nimport { getErrorMessage } from '../../utils/err';\n\nconst URL = 'api/v1/referral-system/referrer/';\n\nexport interface ISetReferralParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The signature of the address. The signature is generated by signing the address using wallet.\n * Use `signTermsOfService` or `signLbtcDestinationAddr` functions.\n */\n signature: string;\n /**\n * The captcha token.\n */\n referrerCode: string;\n /**\n * The typed data object used to generate the signature if using a network fee authorization signature.\n */\n eip712Data?: string;\n /**\n * The public key (required for Starknet).\n */\n pubKey?: string;\n}\n\n/**\n * Set a referral code.\n *\n * @param {ISetReferralParams} The parameters for set referral.\n * @returns {Promise<void>} Nothing.\n * @exception {Error}\n */\nexport async function setReferral({\n address,\n signature,\n eip712Data,\n referrerCode,\n pubKey,\n env,\n}: ISetReferralParams): Promise<void> {\n const { baseApiUrl } = getApiConfig(env);\n\n const requestParams = {\n referrer_code: referrerCode,\n signature,\n signature_typed_data: eip712Data,\n ...(pubKey && { public_key: pubKey }),\n };\n\n try {\n await axios.post(`${URL}${address}`, requestParams, {\n baseURL: baseApiUrl,\n });\n\n return undefined;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n throw new Error(errorMsg);\n }\n}\n","/**\n * Deposit Status Utilities\n *\n * Centralized logic for determining deposit status based on notarization state,\n * confirmations, and other factors. This module provides a single source of truth\n * for deposit status that can be used by the SDK demo, apps/main, and other consumers.\n *\n * Status determination is based on both notarization status and block confirmations.\n * The notarization status from the backend is the primary source of truth for where\n * in the flow a deposit currently is.\n *\n * @module shared/deposits/depositStatus\n */\n\nimport {\n type Deposit,\n ENotarizationStatus,\n ESessionState,\n} from '../../api-functions/getDepositsByAddress/getDepositsByAddress';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Constants\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Number of confirmations required before a deposit can be claimed.\n * Production/Testnet: 6, Stage/Dev: 3\n */\nexport const REQUIRED_CONFIRMATIONS = 6;\n\n/**\n * Minimum deposit amount that can be claimed (in BTC).\n * Deposits below this amount cannot be minted.\n *\n * @deprecated Use `MIN_STAKE_AMOUNT_BTC` from `@lombard.finance/sdk` instead.\n * This constant is an alias kept for backwards compatibility.\n */\nexport const MIN_CLAIM_AMOUNT_BTC = MIN_STAKE_AMOUNT_BTC;\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Types\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Possible deposit statuses - ordered by lifecycle\n */\nexport type DepositStatus =\n | 'pending_confirmations' // Waiting for BTC block confirmations\n | 'pending_notarization' // Confirmations complete, waiting for notarization service\n | 'claimable' // Notarization approved, ready to be claimed manually\n | 'claiming' // Claim transaction submitted\n | 'claimed' // Successfully claimed (has claimTxHash)\n | 'auto_claimed' // Claimed via GMP (cross-chain messaging)\n | 'expired' // Signature expired, needs re-auth\n | 'failed' // Notarization failed\n | 'restricted' // Sanctioned or restricted\n | 'too_small'; // Amount below minimum\n\n/**\n * Status severity for UI styling\n */\nexport type StatusSeverity =\n | 'info'\n | 'warning'\n | 'success'\n | 'error'\n | 'neutral';\n\n/**\n * Status display configuration\n */\nexport interface DepositStatusDisplay {\n /** Human-readable label for the status */\n label: string;\n /** Severity level for styling */\n severity: StatusSeverity;\n /** Detailed description of the status */\n description: string;\n /** Whether the deposit is in a terminal state (claimed, failed, restricted) */\n isTerminal: boolean;\n /** Whether user action is required */\n requiresAction: boolean;\n}\n\n/**\n * Confirmation progress information\n */\nexport interface ConfirmationProgress {\n /** Current number of confirmations */\n current: number;\n /** Required number of confirmations */\n required: number;\n /** Percentage complete (0-100) */\n percentage: number;\n /** Whether enough confirmations have been received */\n isComplete: boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Core Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Calculate the number of confirmations for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @returns Number of confirmations (0 if either height is missing)\n */\nexport function calcConfirmations(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n): number {\n if (!depositBlockHeight || !currentBlockHeight) {\n return 0;\n }\n // Deposit block height counts as the first confirmation\n return Math.max(0, currentBlockHeight - depositBlockHeight + 1);\n}\n\n/**\n * Get confirmation progress for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @param requiredConfirmations - Number of confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns Confirmation progress info, or null if block heights unavailable\n */\nexport function getConfirmationProgress(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): ConfirmationProgress | null {\n if (currentBlockHeight === undefined || depositBlockHeight === undefined) {\n return null;\n }\n\n const current = calcConfirmations(currentBlockHeight, depositBlockHeight);\n const percentage = Math.min(\n 100,\n Math.round((current / requiredConfirmations) * 100),\n );\n\n return {\n current,\n required: requiredConfirmations,\n percentage,\n isComplete: current >= requiredConfirmations,\n };\n}\n\n/**\n * Determine the status of a deposit\n *\n * Logic priority:\n * 1. Sanctioned → restricted\n * 2. Already claimed → claimed\n * 3. GMP handled → auto_claimed (definitive success, overrides expired/failed)\n * 4. Amount too small → too_small (permanent, re-auth won't help)\n * 5. Notarization failed → failed (terminal, overrides expired)\n * 6. Session expired → expired (recoverable via re-auth)\n * 7. Based on notarization status + proof availability:\n * - PENDING/SUBMITTED without enough confirmations → pending_confirmations\n * - PENDING/SUBMITTED with confirmations → pending_notarization\n * - SESSION_APPROVED with proof → claimable\n * - SESSION_APPROVED without proof → pending_notarization (edge case)\n *\n * @param deposit - The deposit object from the SDK\n * @param currentBlockHeight - Current BTC block height (optional, enhances accuracy)\n * @param requiredConfirmations - Confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns The deposit status\n */\nexport function getDepositStatus(\n deposit: Deposit,\n currentBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): DepositStatus {\n // 1. Check for sanctioned/restricted first\n if (deposit.sanctioned) {\n return 'restricted';\n }\n\n // 2. Check if already claimed\n if (deposit.isClaimed || deposit.claimTxHash) {\n return 'claimed';\n }\n\n // 3. Check for GMP auto-claim (definitive success, overrides expired/failed)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_GMP_HANDLED\n ) {\n return 'auto_claimed';\n }\n\n // 4. Check if amount is too small (permanent, re-auth won't help)\n const amountBtc = deposit.amount?.toNumber?.() ?? Number(deposit.amount);\n if (amountBtc > 0 && amountBtc < MIN_STAKE_AMOUNT_BTC) {\n return 'too_small';\n }\n\n // 5. Check for notarization failure (terminal, overrides expired)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_FAILED\n ) {\n return 'failed';\n }\n\n // 6. Check if the notarization session has expired (recoverable via re-auth)\n if (deposit.sessionState === ESessionState.SESSION_STATE_EXPIRED) {\n return 'expired';\n }\n\n // 7. Determine status based on notarization status and proof availability\n const hasProof = !!deposit.proof && !!deposit.rawPayload;\n const notarizationStatus = deposit.notarizationStatus;\n\n // Check confirmations only if we have block height data\n const confirmations = calcConfirmations(\n currentBlockHeight,\n deposit.blockHeight,\n );\n const hasEnoughConfirmations =\n currentBlockHeight === undefined || confirmations >= requiredConfirmations;\n\n switch (notarizationStatus) {\n case ENotarizationStatus.NOTARIZATION_STATUS_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_GMP_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_SUBMITTED:\n // Still in notarization queue\n // If we know block height and not enough confirmations, show that\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n // Otherwise, we're waiting for notarization\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_SESSION_APPROVED:\n // Notarization approved\n if (hasProof) {\n return 'claimable';\n }\n // Edge case: approved but no proof yet (should be rare)\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_UNSPECIFIED:\n default:\n // Unknown status - check confirmations if we can\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n return 'pending_notarization';\n }\n}\n\n/**\n * Get display configuration for a deposit status\n *\n * @param status - The deposit status\n * @returns Display configuration with label, severity, and description\n */\nexport function getDepositStatusDisplay(\n status: DepositStatus,\n): DepositStatusDisplay {\n switch (status) {\n case 'pending_confirmations':\n return {\n label: 'Pending Confirmations',\n severity: 'warning',\n description: `Waiting for Bitcoin block confirmations (${REQUIRED_CONFIRMATIONS} required)`,\n isTerminal: false,\n requiresAction: false,\n };\n case 'pending_notarization':\n return {\n label: 'Pending Notarization',\n severity: 'info',\n description:\n 'Confirmations complete, waiting for notarization service to generate proof',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimable':\n return {\n label: 'Claimable',\n severity: 'success',\n description: 'Ready to mint - proof available, claim to receive tokens',\n isTerminal: false,\n requiresAction: true,\n };\n case 'claiming':\n return {\n label: 'Claiming',\n severity: 'info',\n description: 'Claim transaction in progress',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimed':\n return {\n label: 'Claimed',\n severity: 'neutral',\n description: 'Tokens have been minted to your address',\n isTerminal: true,\n requiresAction: false,\n };\n case 'auto_claimed':\n return {\n label: 'Auto-Claimed',\n severity: 'success',\n description: 'Automatically claimed via cross-chain messaging (GMP)',\n isTerminal: true,\n requiresAction: false,\n };\n case 'expired':\n return {\n label: 'Expired',\n severity: 'error',\n description: 'Fee signature expired, requires re-authorization',\n isTerminal: false,\n requiresAction: true,\n };\n case 'failed':\n return {\n label: 'Failed',\n severity: 'error',\n description: 'Notarization failed - contact support',\n isTerminal: true,\n requiresAction: false,\n };\n case 'restricted':\n return {\n label: 'Restricted',\n severity: 'error',\n description: 'This deposit is restricted or sanctioned',\n isTerminal: true,\n requiresAction: false,\n };\n case 'too_small':\n return {\n label: 'Too Small',\n severity: 'neutral',\n description: `Amount below minimum claimable amount (${MIN_STAKE_AMOUNT_BTC} BTC)`,\n isTerminal: true,\n requiresAction: false,\n };\n }\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Helper Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Check if a deposit can be claimed manually\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if the deposit is in claimable state\n */\nexport function isDepositClaimable(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n return getDepositStatus(deposit, currentBlockHeight) === 'claimable';\n}\n\n/**\n * Check if a deposit is in a pending state (confirmations or notarization)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is pending\n */\nexport function isDepositPending(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n return (\n status === 'pending_confirmations' || status === 'pending_notarization'\n );\n}\n\n/**\n * Check if a deposit is in a terminal state (no further action possible)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is in terminal state\n */\nexport function isDepositTerminal(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.isTerminal;\n}\n\n/**\n * Check if a deposit requires user action\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if user action is required\n */\nexport function depositRequiresAction(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.requiresAction;\n}\n"],"names":["getLBTCExchangeRate","env","chainId","ChainId","amount","toSatoshi","baseApiUrl","getApiConfig","chainIdName","getChainNameById","data","axios","amountOut","BigNumber","exchangeRate","minAmount","MIN_STAKE_AMOUNT_BTC","URL","setReferral","address","signature","eip712Data","referrerCode","pubKey","requestParams","error","errorMsg","getErrorMessage","REQUIRED_CONFIRMATIONS","MIN_CLAIM_AMOUNT_BTC","calcConfirmations","currentBlockHeight","depositBlockHeight","getConfirmationProgress","requiredConfirmations","current","percentage","getDepositStatus","deposit","ENotarizationStatus","amountBtc","_b","_a","ESessionState","hasProof","notarizationStatus","confirmations","hasEnoughConfirmations","getDepositStatusDisplay","status","isDepositClaimable","isDepositPending","isDepositTerminal","depositRequiresAction"],"mappings":"8VAwDA,eAAsBA,EAAoB,CACxC,IAAAC,EACA,QAAAC,EAAUC,EAAAA,QAAQ,SAClB,OAAAC,EAASC,EAAAA,UAAU,CAAC,CACtB,EAAsE,CACpE,KAAM,CAAE,WAAAC,CAAA,EAAeC,EAAAA,aAAaN,CAAG,EACjCO,EAAcC,EAAAA,iBAAiBP,CAAO,EAEtC,CAAE,KAAAQ,CAAA,EAAS,MAAMC,EAAM,IAC3B,wBAAwBH,CAAW,GACnC,CAAE,QAASF,EAAY,OAAQ,CAAE,OAAAF,EAAO,CAAE,EAGtCQ,EAAYC,EAAUH,EAAK,UAAU,EAAE,SAAA,EACvCI,EAAeD,EAAUT,CAAM,EAAE,UAAUM,EAAK,UAAU,EAAE,SAAA,EAC5DK,EAAYV,EAAAA,UAAUW,EAAAA,oBAAoB,EAAE,SAAA,EAElD,MAAO,CAAE,UAAAJ,EAAW,aAAAE,EAAc,UAAAC,CAAA,CACpC,CCpEA,MAAME,EAAM,mCAiCZ,eAAsBC,EAAY,CAChC,QAAAC,EACA,UAAAC,EACA,WAAAC,EACA,aAAAC,EACA,OAAAC,EACA,IAAAtB,CACF,EAAsC,CACpC,KAAM,CAAE,WAAAK,CAAA,EAAeC,EAAAA,aAAaN,CAAG,EAEjCuB,EAAgB,CACpB,cAAeF,EACf,UAAAF,EACA,qBAAsBC,EACtB,GAAIE,GAAU,CAAE,WAAYA,CAAA,CAAO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,EAEpB,IAAK,YACH,MAAO,CACL,MAAO,YACP,SAAU,UACV,YAAa,0CAA0CZ,EAAAA,oBAAoB,QAC3E,WAAY,GACZ,eAAgB,EAAA,CAClB,CAEN,CAaO,SAASkC,EACdZ,EACAP,EACS,CACT,OAAOM,EAAiBC,EAASP,CAAkB,IAAM,WAC3D,CASO,SAASoB,EACdb,EACAP,EACS,CACT,MAAMkB,EAASZ,EAAiBC,EAASP,CAAkB,EAC3D,OACEkB,IAAW,yBAA2BA,IAAW,sBAErD,CASO,SAASG,EACdd,EACAP,EACS,CACT,MAAMkB,EAASZ,EAAiBC,EAASP,CAAkB,EAE3D,OADgBiB,EAAwBC,CAAM,EAC/B,UACjB,CASO,SAASI,EACdf,EACAP,EACS,CACT,MAAMkB,EAASZ,EAAiBC,EAASP,CAAkB,EAE3D,OADgBiB,EAAwBC,CAAM,EAC/B,cACjB"}
|
|
1
|
+
{"version":3,"file":"depositStatus-DUXMloTa.cjs","sources":["../../src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.ts","../../src/api-functions/setReferral/setReferral.ts","../../src/shared/deposits/depositStatus.ts"],"sourcesContent":["import axios from 'axios';\nimport BigNumber from 'bignumber.js';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { getChainNameById } from '../../common/blockchain-identifier';\nimport { ChainId } from '../../common/chains';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\nimport { IEnvParam } from '../../common/parameters';\nimport { toSatoshi } from '../../utils/satoshi';\n\ntype ExchangeRateResponse = {\n amount_out: string;\n};\n\nexport interface IgetLBTCExchangeRateParams extends IEnvParam {\n /**\n * The optional chain id of the asset to get the exchange rate for.\n * Note: Exchange rate it the same for all chains.\n *\n * @default OChainId.ethereum\n */\n chainId?: ChainId;\n /**\n * The amount of the LBTC (in satoshis) that a user would like to exchange to BTC.\n */\n amount?: BigNumber.Value;\n}\n\nexport interface IgetLBTCExchangeRateResponse {\n /**\n * The exchanged amount (in satoshis).\n */\n amountOut: number;\n /**\n * The exchange rate for LBTC/BTC.\n */\n exchangeRate: number;\n /**\n * The minimum amount of BTC eligible for staking (in satoshis).\n */\n minAmount: number;\n}\n\n/**\n * Retrieves the exchange rate for LBTC.\n *\n * @deprecated This API endpoint is deprecated and will be removed in a future version.\n * The exchange rate is now always 1:1 as LBTC is a rebasing token.\n *\n * @param {IgetLBTCExchangeRateParams} parameters - The parameters.\n * @param {BigNumber.Value} parameters.amount - The optional amount to be exchanged.\n * @param {ChainId} parameters.chainId - The optional chain id.\n * @param {Env} parameters.env - The optional environment identifier.\n *\n * @returns {Promise<IgetLBTCExchangeRateResponse>} - The exchange rate.\n */\nexport async function getLBTCExchangeRate({\n env,\n chainId = ChainId.ethereum,\n amount = toSatoshi(1),\n}: IgetLBTCExchangeRateParams): Promise<IgetLBTCExchangeRateResponse> {\n const { baseApiUrl } = getApiConfig(env);\n const chainIdName = getChainNameById(chainId);\n\n const { data } = await axios.get<ExchangeRateResponse>(\n `api/v1/exchange/rate/${chainIdName}`,\n { baseURL: baseApiUrl, params: { amount } },\n );\n\n const amountOut = BigNumber(data.amount_out).toNumber();\n const exchangeRate = BigNumber(amount).dividedBy(data.amount_out).toNumber();\n const minAmount = toSatoshi(MIN_STAKE_AMOUNT_BTC).toNumber();\n\n return { amountOut, exchangeRate, minAmount };\n}\n","import axios from 'axios';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { IEnvParam } from '../../common/parameters';\nimport { getErrorMessage } from '../../utils/err';\n\nconst URL = 'api/v1/referral-system/referrer/';\n\nexport interface ISetReferralParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The signature of the address. The signature is generated by signing the address using wallet.\n * Use `signTermsOfService` or `signLbtcDestinationAddr` functions.\n */\n signature: string;\n /**\n * The captcha token.\n */\n referrerCode: string;\n /**\n * The typed data object used to generate the signature if using a network fee authorization signature.\n */\n eip712Data?: string;\n /**\n * The public key (required for Starknet).\n */\n pubKey?: string;\n}\n\n/**\n * Set a referral code.\n *\n * @param {ISetReferralParams} The parameters for set referral.\n * @returns {Promise<void>} Nothing.\n * @exception {Error}\n */\nexport async function setReferral({\n address,\n signature,\n eip712Data,\n referrerCode,\n pubKey,\n env,\n}: ISetReferralParams): Promise<void> {\n const { baseApiUrl } = getApiConfig(env);\n\n const requestParams = {\n referrer_code: referrerCode,\n signature,\n signature_typed_data: eip712Data,\n ...(pubKey && { public_key: pubKey }),\n };\n\n try {\n await axios.post(`${URL}${address}`, requestParams, {\n baseURL: baseApiUrl,\n });\n\n return undefined;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n throw new Error(errorMsg);\n }\n}\n","/**\n * Deposit Status Utilities\n *\n * Centralized logic for determining deposit status based on notarization state,\n * confirmations, and other factors. This module provides a single source of truth\n * for deposit status that can be used by the SDK demo, apps/main, and other consumers.\n *\n * Status determination is based on both notarization status and block confirmations.\n * The notarization status from the backend is the primary source of truth for where\n * in the flow a deposit currently is.\n *\n * @module shared/deposits/depositStatus\n */\n\nimport {\n type Deposit,\n ENotarizationStatus,\n ESessionState,\n} from '../../api-functions/getDepositsByAddress/getDepositsByAddress';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Constants\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Number of confirmations required before a deposit can be claimed.\n * Production/Testnet: 6, Stage/Dev: 3\n */\nexport const REQUIRED_CONFIRMATIONS = 6;\n\n/**\n * Minimum deposit amount that can be claimed (in BTC).\n * Deposits below this amount cannot be minted.\n *\n * @deprecated Use `MIN_STAKE_AMOUNT_BTC` from `@lombard.finance/sdk` instead.\n * This constant is an alias kept for backwards compatibility.\n */\nexport const MIN_CLAIM_AMOUNT_BTC = MIN_STAKE_AMOUNT_BTC;\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Types\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Possible deposit statuses - ordered by lifecycle\n */\nexport type DepositStatus =\n | 'pending_confirmations' // Waiting for BTC block confirmations\n | 'pending_notarization' // Confirmations complete, waiting for notarization service\n | 'claimable' // Notarization approved, ready to be claimed manually\n | 'claiming' // Claim transaction submitted\n | 'claimed' // Successfully claimed (has claimTxHash)\n | 'auto_claimed' // Claimed via GMP (cross-chain messaging)\n | 'expired' // Signature expired, needs re-auth\n | 'failed' // Notarization failed\n | 'restricted' // Sanctioned or restricted\n | 'too_small'; // Amount below minimum\n\n/**\n * Status severity for UI styling\n */\nexport type StatusSeverity =\n | 'info'\n | 'warning'\n | 'success'\n | 'error'\n | 'neutral';\n\n/**\n * Status display configuration\n */\nexport interface DepositStatusDisplay {\n /** Human-readable label for the status */\n label: string;\n /** Severity level for styling */\n severity: StatusSeverity;\n /** Detailed description of the status */\n description: string;\n /** Whether the deposit is in a terminal state (claimed, failed, restricted) */\n isTerminal: boolean;\n /** Whether user action is required */\n requiresAction: boolean;\n}\n\n/**\n * Confirmation progress information\n */\nexport interface ConfirmationProgress {\n /** Current number of confirmations */\n current: number;\n /** Required number of confirmations */\n required: number;\n /** Percentage complete (0-100) */\n percentage: number;\n /** Whether enough confirmations have been received */\n isComplete: boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Core Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Calculate the number of confirmations for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @returns Number of confirmations (0 if either height is missing)\n */\nexport function calcConfirmations(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n): number {\n if (!depositBlockHeight || !currentBlockHeight) {\n return 0;\n }\n // Deposit block height counts as the first confirmation\n return Math.max(0, currentBlockHeight - depositBlockHeight + 1);\n}\n\n/**\n * Get confirmation progress for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @param requiredConfirmations - Number of confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns Confirmation progress info, or null if block heights unavailable\n */\nexport function getConfirmationProgress(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): ConfirmationProgress | null {\n if (currentBlockHeight === undefined || depositBlockHeight === undefined) {\n return null;\n }\n\n const current = calcConfirmations(currentBlockHeight, depositBlockHeight);\n const percentage = Math.min(\n 100,\n Math.round((current / requiredConfirmations) * 100),\n );\n\n return {\n current,\n required: requiredConfirmations,\n percentage,\n isComplete: current >= requiredConfirmations,\n };\n}\n\n/**\n * Determine the status of a deposit\n *\n * Logic priority:\n * 1. Sanctioned → restricted\n * 2. Already claimed → claimed\n * 3. GMP handled → auto_claimed (definitive success, overrides expired/failed)\n * 4. Amount too small → too_small (permanent, re-auth won't help)\n * 5. Notarization failed → failed (terminal, overrides expired)\n * 6. Session expired → expired (recoverable via re-auth)\n * 7. Based on notarization status + proof availability:\n * - PENDING/SUBMITTED without enough confirmations → pending_confirmations\n * - PENDING/SUBMITTED with confirmations → pending_notarization\n * - SESSION_APPROVED with proof → claimable\n * - SESSION_APPROVED without proof → pending_notarization (edge case)\n *\n * @param deposit - The deposit object from the SDK\n * @param currentBlockHeight - Current BTC block height (optional, enhances accuracy)\n * @param requiredConfirmations - Confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns The deposit status\n */\nexport function getDepositStatus(\n deposit: Deposit,\n currentBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): DepositStatus {\n // 1. Check for sanctioned/restricted first\n if (deposit.sanctioned) {\n return 'restricted';\n }\n\n // 2. Check if already claimed\n if (deposit.isClaimed || deposit.claimTxHash) {\n return 'claimed';\n }\n\n // 3. Check for GMP auto-claim (definitive success, overrides expired/failed)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_GMP_HANDLED\n ) {\n return 'auto_claimed';\n }\n\n // 4. Check if amount is too small (permanent, re-auth won't help)\n const amountBtc = deposit.amount?.toNumber?.() ?? Number(deposit.amount);\n if (amountBtc > 0 && amountBtc < MIN_STAKE_AMOUNT_BTC) {\n return 'too_small';\n }\n\n // 5. Check for notarization failure (terminal, overrides expired)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_FAILED\n ) {\n return 'failed';\n }\n\n // 6. Check if the notarization session has expired (recoverable via re-auth)\n if (deposit.sessionState === ESessionState.SESSION_STATE_EXPIRED) {\n return 'expired';\n }\n\n // 7. Determine status based on notarization status and proof availability\n const hasProof = !!deposit.proof && !!deposit.rawPayload;\n const notarizationStatus = deposit.notarizationStatus;\n\n // Check confirmations only if we have block height data\n const confirmations = calcConfirmations(\n currentBlockHeight,\n deposit.blockHeight,\n );\n const hasEnoughConfirmations =\n currentBlockHeight === undefined || confirmations >= requiredConfirmations;\n\n switch (notarizationStatus) {\n case ENotarizationStatus.NOTARIZATION_STATUS_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_GMP_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_SUBMITTED:\n // Still in notarization queue\n // If we know block height and not enough confirmations, show that\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n // Otherwise, we're waiting for notarization\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_SESSION_APPROVED:\n // Notarization approved\n if (hasProof) {\n return 'claimable';\n }\n // Edge case: approved but no proof yet (should be rare)\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_UNSPECIFIED:\n default:\n // Unknown status - check confirmations if we can\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n return 'pending_notarization';\n }\n}\n\n/**\n * Get display configuration for a deposit status\n *\n * @param status - The deposit status\n * @returns Display configuration with label, severity, and description\n */\nexport function getDepositStatusDisplay(\n status: DepositStatus,\n): DepositStatusDisplay {\n switch (status) {\n case 'pending_confirmations':\n return {\n label: 'Pending Confirmations',\n severity: 'warning',\n description: `Waiting for Bitcoin block confirmations (${REQUIRED_CONFIRMATIONS} required)`,\n isTerminal: false,\n requiresAction: false,\n };\n case 'pending_notarization':\n return {\n label: 'Pending Notarization',\n severity: 'info',\n description:\n 'Confirmations complete, waiting for notarization service to generate proof',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimable':\n return {\n label: 'Claimable',\n severity: 'success',\n description: 'Ready to mint - proof available, claim to receive tokens',\n isTerminal: false,\n requiresAction: true,\n };\n case 'claiming':\n return {\n label: 'Claiming',\n severity: 'info',\n description: 'Claim transaction in progress',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimed':\n return {\n label: 'Claimed',\n severity: 'neutral',\n description: 'Tokens have been minted to your address',\n isTerminal: true,\n requiresAction: false,\n };\n case 'auto_claimed':\n return {\n label: 'Auto-Claimed',\n severity: 'success',\n description: 'Automatically claimed via cross-chain messaging (GMP)',\n isTerminal: true,\n requiresAction: false,\n };\n case 'expired':\n return {\n label: 'Expired',\n severity: 'error',\n description: 'Fee signature expired, requires re-authorization',\n isTerminal: false,\n requiresAction: true,\n };\n case 'failed':\n return {\n label: 'Failed',\n severity: 'error',\n description: 'Notarization failed - contact support',\n isTerminal: true,\n requiresAction: false,\n };\n case 'restricted':\n return {\n label: 'Restricted',\n severity: 'error',\n description: 'This deposit is restricted or sanctioned',\n isTerminal: true,\n requiresAction: false,\n };\n case 'too_small':\n return {\n label: 'Too Small',\n severity: 'neutral',\n description: `Amount below minimum claimable amount (${MIN_STAKE_AMOUNT_BTC} BTC)`,\n isTerminal: true,\n requiresAction: false,\n };\n }\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Helper Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Check if a deposit can be claimed manually\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if the deposit is in claimable state\n */\nexport function isDepositClaimable(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n return getDepositStatus(deposit, currentBlockHeight) === 'claimable';\n}\n\n/**\n * Check if a deposit is in a pending state (confirmations or notarization)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is pending\n */\nexport function isDepositPending(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n return (\n status === 'pending_confirmations' || status === 'pending_notarization'\n );\n}\n\n/**\n * Check if a deposit is in a terminal state (no further action possible)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is in terminal state\n */\nexport function isDepositTerminal(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.isTerminal;\n}\n\n/**\n * Check if a deposit requires user action\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if user action is required\n */\nexport function depositRequiresAction(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.requiresAction;\n}\n"],"names":["getLBTCExchangeRate","env","chainId","ChainId","amount","toSatoshi","baseApiUrl","getApiConfig","chainIdName","getChainNameById","data","axios","amountOut","BigNumber","exchangeRate","minAmount","MIN_STAKE_AMOUNT_BTC","URL","setReferral","address","signature","eip712Data","referrerCode","pubKey","requestParams","error","errorMsg","getErrorMessage","REQUIRED_CONFIRMATIONS","MIN_CLAIM_AMOUNT_BTC","calcConfirmations","currentBlockHeight","depositBlockHeight","getConfirmationProgress","requiredConfirmations","current","percentage","getDepositStatus","deposit","ENotarizationStatus","amountBtc","_b","_a","ESessionState","hasProof","notarizationStatus","confirmations","hasEnoughConfirmations","getDepositStatusDisplay","status","isDepositClaimable","isDepositPending","isDepositTerminal","depositRequiresAction"],"mappings":"6WAwDA,eAAsBA,EAAoB,CACxC,IAAAC,EACA,QAAAC,EAAUC,EAAAA,QA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UACjB,CASO,SAASI,EACdf,EACAP,EACS,CACT,MAAMkB,EAASZ,EAAiBC,EAASP,CAAkB,EAE3D,OADgBiB,EAAwBC,CAAM,EAC/B,cACjB"}
|
|
@@ -3,10 +3,10 @@ import T from "bignumber.js";
|
|
|
3
3
|
import { getApiConfig as _ } from "./api-config-Dm6dR85f.js";
|
|
4
4
|
import { getChainNameById as g } from "./blockchain-identifier-BkASqCgZ.js";
|
|
5
5
|
import { ChainId as I } from "./token-addresses-DVnRPyu4.js";
|
|
6
|
-
import { MIN_STAKE_AMOUNT_BTC as m } from "./
|
|
6
|
+
import { MIN_STAKE_AMOUNT_BTC as m } from "./storeNetworkFeeSignature-sCt4_nHr.js";
|
|
7
7
|
import { toSatoshi as p } from "./satoshi-CSoJBXc6.js";
|
|
8
|
-
import { getErrorMessage as b } from "./tokens-
|
|
9
|
-
import { ENotarizationStatus as o, ESessionState as y } from "./ReferralsClient-
|
|
8
|
+
import { getErrorMessage as b } from "./tokens-BUrC15ra.js";
|
|
9
|
+
import { ENotarizationStatus as o, ESessionState as y } from "./ReferralsClient-BNwB6wO4.js";
|
|
10
10
|
async function q({
|
|
11
11
|
env: e,
|
|
12
12
|
chainId: i = I.ethereum,
|
|
@@ -205,4 +205,4 @@ export {
|
|
|
205
205
|
F as isDepositTerminal,
|
|
206
206
|
z as setReferral
|
|
207
207
|
};
|
|
208
|
-
//# sourceMappingURL=depositStatus-
|
|
208
|
+
//# sourceMappingURL=depositStatus-hmXphYhu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depositStatus-Cgd_GDUt.js","sources":["../../src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.ts","../../src/api-functions/setReferral/setReferral.ts","../../src/shared/deposits/depositStatus.ts"],"sourcesContent":["import axios from 'axios';\nimport BigNumber from 'bignumber.js';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { getChainNameById } from '../../common/blockchain-identifier';\nimport { ChainId } from '../../common/chains';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\nimport { IEnvParam } from '../../common/parameters';\nimport { toSatoshi } from '../../utils/satoshi';\n\ntype ExchangeRateResponse = {\n amount_out: string;\n};\n\nexport interface IgetLBTCExchangeRateParams extends IEnvParam {\n /**\n * The optional chain id of the asset to get the exchange rate for.\n * Note: Exchange rate it the same for all chains.\n *\n * @default OChainId.ethereum\n */\n chainId?: ChainId;\n /**\n * The amount of the LBTC (in satoshis) that a user would like to exchange to BTC.\n */\n amount?: BigNumber.Value;\n}\n\nexport interface IgetLBTCExchangeRateResponse {\n /**\n * The exchanged amount (in satoshis).\n */\n amountOut: number;\n /**\n * The exchange rate for LBTC/BTC.\n */\n exchangeRate: number;\n /**\n * The minimum amount of BTC eligible for staking (in satoshis).\n */\n minAmount: number;\n}\n\n/**\n * Retrieves the exchange rate for LBTC.\n *\n * @deprecated This API endpoint is deprecated and will be removed in a future version.\n * The exchange rate is now always 1:1 as LBTC is a rebasing token.\n *\n * @param {IgetLBTCExchangeRateParams} parameters - The parameters.\n * @param {BigNumber.Value} parameters.amount - The optional amount to be exchanged.\n * @param {ChainId} parameters.chainId - The optional chain id.\n * @param {Env} parameters.env - The optional environment identifier.\n *\n * @returns {Promise<IgetLBTCExchangeRateResponse>} - The exchange rate.\n */\nexport async function getLBTCExchangeRate({\n env,\n chainId = ChainId.ethereum,\n amount = toSatoshi(1),\n}: IgetLBTCExchangeRateParams): Promise<IgetLBTCExchangeRateResponse> {\n const { baseApiUrl } = getApiConfig(env);\n const chainIdName = getChainNameById(chainId);\n\n const { data } = await axios.get<ExchangeRateResponse>(\n `api/v1/exchange/rate/${chainIdName}`,\n { baseURL: baseApiUrl, params: { amount } },\n );\n\n const amountOut = BigNumber(data.amount_out).toNumber();\n const exchangeRate = BigNumber(amount).dividedBy(data.amount_out).toNumber();\n const minAmount = toSatoshi(MIN_STAKE_AMOUNT_BTC).toNumber();\n\n return { amountOut, exchangeRate, minAmount };\n}\n","import axios from 'axios';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { IEnvParam } from '../../common/parameters';\nimport { getErrorMessage } from '../../utils/err';\n\nconst URL = 'api/v1/referral-system/referrer/';\n\nexport interface ISetReferralParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The signature of the address. The signature is generated by signing the address using wallet.\n * Use `signTermsOfService` or `signLbtcDestinationAddr` functions.\n */\n signature: string;\n /**\n * The captcha token.\n */\n referrerCode: string;\n /**\n * The typed data object used to generate the signature if using a network fee authorization signature.\n */\n eip712Data?: string;\n /**\n * The public key (required for Starknet).\n */\n pubKey?: string;\n}\n\n/**\n * Set a referral code.\n *\n * @param {ISetReferralParams} The parameters for set referral.\n * @returns {Promise<void>} Nothing.\n * @exception {Error}\n */\nexport async function setReferral({\n address,\n signature,\n eip712Data,\n referrerCode,\n pubKey,\n env,\n}: ISetReferralParams): Promise<void> {\n const { baseApiUrl } = getApiConfig(env);\n\n const requestParams = {\n referrer_code: referrerCode,\n signature,\n signature_typed_data: eip712Data,\n ...(pubKey && { public_key: pubKey }),\n };\n\n try {\n await axios.post(`${URL}${address}`, requestParams, {\n baseURL: baseApiUrl,\n });\n\n return undefined;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n throw new Error(errorMsg);\n }\n}\n","/**\n * Deposit Status Utilities\n *\n * Centralized logic for determining deposit status based on notarization state,\n * confirmations, and other factors. This module provides a single source of truth\n * for deposit status that can be used by the SDK demo, apps/main, and other consumers.\n *\n * Status determination is based on both notarization status and block confirmations.\n * The notarization status from the backend is the primary source of truth for where\n * in the flow a deposit currently is.\n *\n * @module shared/deposits/depositStatus\n */\n\nimport {\n type Deposit,\n ENotarizationStatus,\n ESessionState,\n} from '../../api-functions/getDepositsByAddress/getDepositsByAddress';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Constants\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Number of confirmations required before a deposit can be claimed.\n * Production/Testnet: 6, Stage/Dev: 3\n */\nexport const REQUIRED_CONFIRMATIONS = 6;\n\n/**\n * Minimum deposit amount that can be claimed (in BTC).\n * Deposits below this amount cannot be minted.\n *\n * @deprecated Use `MIN_STAKE_AMOUNT_BTC` from `@lombard.finance/sdk` instead.\n * This constant is an alias kept for backwards compatibility.\n */\nexport const MIN_CLAIM_AMOUNT_BTC = MIN_STAKE_AMOUNT_BTC;\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Types\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Possible deposit statuses - ordered by lifecycle\n */\nexport type DepositStatus =\n | 'pending_confirmations' // Waiting for BTC block confirmations\n | 'pending_notarization' // Confirmations complete, waiting for notarization service\n | 'claimable' // Notarization approved, ready to be claimed manually\n | 'claiming' // Claim transaction submitted\n | 'claimed' // Successfully claimed (has claimTxHash)\n | 'auto_claimed' // Claimed via GMP (cross-chain messaging)\n | 'expired' // Signature expired, needs re-auth\n | 'failed' // Notarization failed\n | 'restricted' // Sanctioned or restricted\n | 'too_small'; // Amount below minimum\n\n/**\n * Status severity for UI styling\n */\nexport type StatusSeverity =\n | 'info'\n | 'warning'\n | 'success'\n | 'error'\n | 'neutral';\n\n/**\n * Status display configuration\n */\nexport interface DepositStatusDisplay {\n /** Human-readable label for the status */\n label: string;\n /** Severity level for styling */\n severity: StatusSeverity;\n /** Detailed description of the status */\n description: string;\n /** Whether the deposit is in a terminal state (claimed, failed, restricted) */\n isTerminal: boolean;\n /** Whether user action is required */\n requiresAction: boolean;\n}\n\n/**\n * Confirmation progress information\n */\nexport interface ConfirmationProgress {\n /** Current number of confirmations */\n current: number;\n /** Required number of confirmations */\n required: number;\n /** Percentage complete (0-100) */\n percentage: number;\n /** Whether enough confirmations have been received */\n isComplete: boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Core Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Calculate the number of confirmations for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @returns Number of confirmations (0 if either height is missing)\n */\nexport function calcConfirmations(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n): number {\n if (!depositBlockHeight || !currentBlockHeight) {\n return 0;\n }\n // Deposit block height counts as the first confirmation\n return Math.max(0, currentBlockHeight - depositBlockHeight + 1);\n}\n\n/**\n * Get confirmation progress for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @param requiredConfirmations - Number of confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns Confirmation progress info, or null if block heights unavailable\n */\nexport function getConfirmationProgress(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): ConfirmationProgress | null {\n if (currentBlockHeight === undefined || depositBlockHeight === undefined) {\n return null;\n }\n\n const current = calcConfirmations(currentBlockHeight, depositBlockHeight);\n const percentage = Math.min(\n 100,\n Math.round((current / requiredConfirmations) * 100),\n );\n\n return {\n current,\n required: requiredConfirmations,\n percentage,\n isComplete: current >= requiredConfirmations,\n };\n}\n\n/**\n * Determine the status of a deposit\n *\n * Logic priority:\n * 1. Sanctioned → restricted\n * 2. Already claimed → claimed\n * 3. GMP handled → auto_claimed (definitive success, overrides expired/failed)\n * 4. Amount too small → too_small (permanent, re-auth won't help)\n * 5. Notarization failed → failed (terminal, overrides expired)\n * 6. Session expired → expired (recoverable via re-auth)\n * 7. Based on notarization status + proof availability:\n * - PENDING/SUBMITTED without enough confirmations → pending_confirmations\n * - PENDING/SUBMITTED with confirmations → pending_notarization\n * - SESSION_APPROVED with proof → claimable\n * - SESSION_APPROVED without proof → pending_notarization (edge case)\n *\n * @param deposit - The deposit object from the SDK\n * @param currentBlockHeight - Current BTC block height (optional, enhances accuracy)\n * @param requiredConfirmations - Confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns The deposit status\n */\nexport function getDepositStatus(\n deposit: Deposit,\n currentBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): DepositStatus {\n // 1. Check for sanctioned/restricted first\n if (deposit.sanctioned) {\n return 'restricted';\n }\n\n // 2. Check if already claimed\n if (deposit.isClaimed || deposit.claimTxHash) {\n return 'claimed';\n }\n\n // 3. Check for GMP auto-claim (definitive success, overrides expired/failed)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_GMP_HANDLED\n ) {\n return 'auto_claimed';\n }\n\n // 4. Check if amount is too small (permanent, re-auth won't help)\n const amountBtc = deposit.amount?.toNumber?.() ?? Number(deposit.amount);\n if (amountBtc > 0 && amountBtc < MIN_STAKE_AMOUNT_BTC) {\n return 'too_small';\n }\n\n // 5. Check for notarization failure (terminal, overrides expired)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_FAILED\n ) {\n return 'failed';\n }\n\n // 6. Check if the notarization session has expired (recoverable via re-auth)\n if (deposit.sessionState === ESessionState.SESSION_STATE_EXPIRED) {\n return 'expired';\n }\n\n // 7. Determine status based on notarization status and proof availability\n const hasProof = !!deposit.proof && !!deposit.rawPayload;\n const notarizationStatus = deposit.notarizationStatus;\n\n // Check confirmations only if we have block height data\n const confirmations = calcConfirmations(\n currentBlockHeight,\n deposit.blockHeight,\n );\n const hasEnoughConfirmations =\n currentBlockHeight === undefined || confirmations >= requiredConfirmations;\n\n switch (notarizationStatus) {\n case ENotarizationStatus.NOTARIZATION_STATUS_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_GMP_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_SUBMITTED:\n // Still in notarization queue\n // If we know block height and not enough confirmations, show that\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n // Otherwise, we're waiting for notarization\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_SESSION_APPROVED:\n // Notarization approved\n if (hasProof) {\n return 'claimable';\n }\n // Edge case: approved but no proof yet (should be rare)\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_UNSPECIFIED:\n default:\n // Unknown status - check confirmations if we can\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n return 'pending_notarization';\n }\n}\n\n/**\n * Get display configuration for a deposit status\n *\n * @param status - The deposit status\n * @returns Display configuration with label, severity, and description\n */\nexport function getDepositStatusDisplay(\n status: DepositStatus,\n): DepositStatusDisplay {\n switch (status) {\n case 'pending_confirmations':\n return {\n label: 'Pending Confirmations',\n severity: 'warning',\n description: `Waiting for Bitcoin block confirmations (${REQUIRED_CONFIRMATIONS} required)`,\n isTerminal: false,\n requiresAction: false,\n };\n case 'pending_notarization':\n return {\n label: 'Pending Notarization',\n severity: 'info',\n description:\n 'Confirmations complete, waiting for notarization service to generate proof',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimable':\n return {\n label: 'Claimable',\n severity: 'success',\n description: 'Ready to mint - proof available, claim to receive tokens',\n isTerminal: false,\n requiresAction: true,\n };\n case 'claiming':\n return {\n label: 'Claiming',\n severity: 'info',\n description: 'Claim transaction in progress',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimed':\n return {\n label: 'Claimed',\n severity: 'neutral',\n description: 'Tokens have been minted to your address',\n isTerminal: true,\n requiresAction: false,\n };\n case 'auto_claimed':\n return {\n label: 'Auto-Claimed',\n severity: 'success',\n description: 'Automatically claimed via cross-chain messaging (GMP)',\n isTerminal: true,\n requiresAction: false,\n };\n case 'expired':\n return {\n label: 'Expired',\n severity: 'error',\n description: 'Fee signature expired, requires re-authorization',\n isTerminal: false,\n requiresAction: true,\n };\n case 'failed':\n return {\n label: 'Failed',\n severity: 'error',\n description: 'Notarization failed - contact support',\n isTerminal: true,\n requiresAction: false,\n };\n case 'restricted':\n return {\n label: 'Restricted',\n severity: 'error',\n description: 'This deposit is restricted or sanctioned',\n isTerminal: true,\n requiresAction: false,\n };\n case 'too_small':\n return {\n label: 'Too Small',\n severity: 'neutral',\n description: `Amount below minimum claimable amount (${MIN_STAKE_AMOUNT_BTC} BTC)`,\n isTerminal: true,\n requiresAction: false,\n };\n }\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Helper Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Check if a deposit can be claimed manually\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if the deposit is in claimable state\n */\nexport function isDepositClaimable(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n return getDepositStatus(deposit, currentBlockHeight) === 'claimable';\n}\n\n/**\n * Check if a deposit is in a pending state (confirmations or notarization)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is pending\n */\nexport function isDepositPending(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n return (\n status === 'pending_confirmations' || status === 'pending_notarization'\n );\n}\n\n/**\n * Check if a deposit is in a terminal state (no further action possible)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is in terminal state\n */\nexport function isDepositTerminal(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.isTerminal;\n}\n\n/**\n * Check if a deposit requires user action\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if user action is required\n */\nexport function depositRequiresAction(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.requiresAction;\n}\n"],"names":["getLBTCExchangeRate","env","chainId","ChainId","amount","toSatoshi","baseApiUrl","getApiConfig","chainIdName","getChainNameById","data","axios","amountOut","BigNumber","exchangeRate","minAmount","MIN_STAKE_AMOUNT_BTC","URL","setReferral","address","signature","eip712Data","referrerCode","pubKey","requestParams","error","errorMsg","getErrorMessage","REQUIRED_CONFIRMATIONS","MIN_CLAIM_AMOUNT_BTC","calcConfirmations","currentBlockHeight","depositBlockHeight","getConfirmationProgress","requiredConfirmations","current","percentage","getDepositStatus","deposit","ENotarizationStatus","amountBtc","_b","_a","ESessionState","hasProof","notarizationStatus","confirmations","hasEnoughConfirmations","getDepositStatusDisplay","status","isDepositClaimable","isDepositPending","isDepositTerminal","depositRequiresAction"],"mappings":";;;;;;;;;AAwDA,eAAsBA,EAAoB;AAAA,EACxC,KAAAC;AAAA,EACA,SAAAC,IAAUC,EAAQ;AAAA,EAClB,QAAAC,IAASC,EAAU,CAAC;AACtB,GAAsE;AACpE,QAAM,EAAE,YAAAC,EAAA,IAAeC,EAAaN,CAAG,GACjCO,IAAcC,EAAiBP,CAAO,GAEtC,EAAE,MAAAQ,EAAA,IAAS,MAAMC,EAAM;AAAA,IAC3B,wBAAwBH,CAAW;AAAA,IACnC,EAAE,SAASF,GAAY,QAAQ,EAAE,QAAAF,IAAO;AAAA,EAAE,GAGtCQ,IAAYC,EAAUH,EAAK,UAAU,EAAE,SAAA,GACvCI,IAAeD,EAAUT,CAAM,EAAE,UAAUM,EAAK,UAAU,EAAE,SAAA,GAC5DK,IAAYV,EAAUW,CAAoB,EAAE,SAAA;AAElD,SAAO,EAAE,WAAAJ,GAAW,cAAAE,GAAc,WAAAC,EAAA;AACpC;ACpEA,MAAME,IAAM;AAiCZ,eAAsBC,EAAY;AAAA,EAChC,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,cAAAC;AAAA,EACA,QAAAC;AAAA,EACA,KAAAtB;AACF,GAAsC;AACpC,QAAM,EAAE,YAAAK,EAAA,IAAeC,EAAaN,CAAG,GAEjCuB,IAAgB;AAAA,IACpB,eAAeF;AAAA,IACf,WAAAF;AAAA,IACA,sBAAsBC;AAAA,IACtB,GAAIE,KAAU,EAAE,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;AAAA,QACb,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,IAEpB,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,IAEpB,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,IAEpB,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,IAEpB,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa,0CAA0CZ,CAAoB;AAAA,QAC3E,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,EAClB;AAEN;AAaO,SAASkC,EACdZ,GACAP,GACS;AACT,SAAOM,EAAiBC,GAASP,CAAkB,MAAM;AAC3D;AASO,SAASoB,EACdb,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAC3D,SACEkB,MAAW,2BAA2BA,MAAW;AAErD;AASO,SAASG,EACdd,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAE3D,SADgBiB,EAAwBC,CAAM,EAC/B;AACjB;AASO,SAASI,EACdf,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAE3D,SADgBiB,EAAwBC,CAAM,EAC/B;AACjB;"}
|
|
1
|
+
{"version":3,"file":"depositStatus-hmXphYhu.js","sources":["../../src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.ts","../../src/api-functions/setReferral/setReferral.ts","../../src/shared/deposits/depositStatus.ts"],"sourcesContent":["import axios from 'axios';\nimport BigNumber from 'bignumber.js';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { getChainNameById } from '../../common/blockchain-identifier';\nimport { ChainId } from '../../common/chains';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\nimport { IEnvParam } from '../../common/parameters';\nimport { toSatoshi } from '../../utils/satoshi';\n\ntype ExchangeRateResponse = {\n amount_out: string;\n};\n\nexport interface IgetLBTCExchangeRateParams extends IEnvParam {\n /**\n * The optional chain id of the asset to get the exchange rate for.\n * Note: Exchange rate it the same for all chains.\n *\n * @default OChainId.ethereum\n */\n chainId?: ChainId;\n /**\n * The amount of the LBTC (in satoshis) that a user would like to exchange to BTC.\n */\n amount?: BigNumber.Value;\n}\n\nexport interface IgetLBTCExchangeRateResponse {\n /**\n * The exchanged amount (in satoshis).\n */\n amountOut: number;\n /**\n * The exchange rate for LBTC/BTC.\n */\n exchangeRate: number;\n /**\n * The minimum amount of BTC eligible for staking (in satoshis).\n */\n minAmount: number;\n}\n\n/**\n * Retrieves the exchange rate for LBTC.\n *\n * @deprecated This API endpoint is deprecated and will be removed in a future version.\n * The exchange rate is now always 1:1 as LBTC is a rebasing token.\n *\n * @param {IgetLBTCExchangeRateParams} parameters - The parameters.\n * @param {BigNumber.Value} parameters.amount - The optional amount to be exchanged.\n * @param {ChainId} parameters.chainId - The optional chain id.\n * @param {Env} parameters.env - The optional environment identifier.\n *\n * @returns {Promise<IgetLBTCExchangeRateResponse>} - The exchange rate.\n */\nexport async function getLBTCExchangeRate({\n env,\n chainId = ChainId.ethereum,\n amount = toSatoshi(1),\n}: IgetLBTCExchangeRateParams): Promise<IgetLBTCExchangeRateResponse> {\n const { baseApiUrl } = getApiConfig(env);\n const chainIdName = getChainNameById(chainId);\n\n const { data } = await axios.get<ExchangeRateResponse>(\n `api/v1/exchange/rate/${chainIdName}`,\n { baseURL: baseApiUrl, params: { amount } },\n );\n\n const amountOut = BigNumber(data.amount_out).toNumber();\n const exchangeRate = BigNumber(amount).dividedBy(data.amount_out).toNumber();\n const minAmount = toSatoshi(MIN_STAKE_AMOUNT_BTC).toNumber();\n\n return { amountOut, exchangeRate, minAmount };\n}\n","import axios from 'axios';\n\nimport { getApiConfig } from '../../common/api-config';\nimport { IEnvParam } from '../../common/parameters';\nimport { getErrorMessage } from '../../utils/err';\n\nconst URL = 'api/v1/referral-system/referrer/';\n\nexport interface ISetReferralParams extends IEnvParam {\n /**\n * The destination EVM user address where LBTC will be claimed.\n */\n address: string;\n /**\n * The signature of the address. The signature is generated by signing the address using wallet.\n * Use `signTermsOfService` or `signLbtcDestinationAddr` functions.\n */\n signature: string;\n /**\n * The captcha token.\n */\n referrerCode: string;\n /**\n * The typed data object used to generate the signature if using a network fee authorization signature.\n */\n eip712Data?: string;\n /**\n * The public key (required for Starknet).\n */\n pubKey?: string;\n}\n\n/**\n * Set a referral code.\n *\n * @param {ISetReferralParams} The parameters for set referral.\n * @returns {Promise<void>} Nothing.\n * @exception {Error}\n */\nexport async function setReferral({\n address,\n signature,\n eip712Data,\n referrerCode,\n pubKey,\n env,\n}: ISetReferralParams): Promise<void> {\n const { baseApiUrl } = getApiConfig(env);\n\n const requestParams = {\n referrer_code: referrerCode,\n signature,\n signature_typed_data: eip712Data,\n ...(pubKey && { public_key: pubKey }),\n };\n\n try {\n await axios.post(`${URL}${address}`, requestParams, {\n baseURL: baseApiUrl,\n });\n\n return undefined;\n } catch (error) {\n const errorMsg = getErrorMessage(error);\n throw new Error(errorMsg);\n }\n}\n","/**\n * Deposit Status Utilities\n *\n * Centralized logic for determining deposit status based on notarization state,\n * confirmations, and other factors. This module provides a single source of truth\n * for deposit status that can be used by the SDK demo, apps/main, and other consumers.\n *\n * Status determination is based on both notarization status and block confirmations.\n * The notarization status from the backend is the primary source of truth for where\n * in the flow a deposit currently is.\n *\n * @module shared/deposits/depositStatus\n */\n\nimport {\n type Deposit,\n ENotarizationStatus,\n ESessionState,\n} from '../../api-functions/getDepositsByAddress/getDepositsByAddress';\nimport { MIN_STAKE_AMOUNT_BTC } from '../../common/constants';\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Constants\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Number of confirmations required before a deposit can be claimed.\n * Production/Testnet: 6, Stage/Dev: 3\n */\nexport const REQUIRED_CONFIRMATIONS = 6;\n\n/**\n * Minimum deposit amount that can be claimed (in BTC).\n * Deposits below this amount cannot be minted.\n *\n * @deprecated Use `MIN_STAKE_AMOUNT_BTC` from `@lombard.finance/sdk` instead.\n * This constant is an alias kept for backwards compatibility.\n */\nexport const MIN_CLAIM_AMOUNT_BTC = MIN_STAKE_AMOUNT_BTC;\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Types\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Possible deposit statuses - ordered by lifecycle\n */\nexport type DepositStatus =\n | 'pending_confirmations' // Waiting for BTC block confirmations\n | 'pending_notarization' // Confirmations complete, waiting for notarization service\n | 'claimable' // Notarization approved, ready to be claimed manually\n | 'claiming' // Claim transaction submitted\n | 'claimed' // Successfully claimed (has claimTxHash)\n | 'auto_claimed' // Claimed via GMP (cross-chain messaging)\n | 'expired' // Signature expired, needs re-auth\n | 'failed' // Notarization failed\n | 'restricted' // Sanctioned or restricted\n | 'too_small'; // Amount below minimum\n\n/**\n * Status severity for UI styling\n */\nexport type StatusSeverity =\n | 'info'\n | 'warning'\n | 'success'\n | 'error'\n | 'neutral';\n\n/**\n * Status display configuration\n */\nexport interface DepositStatusDisplay {\n /** Human-readable label for the status */\n label: string;\n /** Severity level for styling */\n severity: StatusSeverity;\n /** Detailed description of the status */\n description: string;\n /** Whether the deposit is in a terminal state (claimed, failed, restricted) */\n isTerminal: boolean;\n /** Whether user action is required */\n requiresAction: boolean;\n}\n\n/**\n * Confirmation progress information\n */\nexport interface ConfirmationProgress {\n /** Current number of confirmations */\n current: number;\n /** Required number of confirmations */\n required: number;\n /** Percentage complete (0-100) */\n percentage: number;\n /** Whether enough confirmations have been received */\n isComplete: boolean;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Core Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Calculate the number of confirmations for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @returns Number of confirmations (0 if either height is missing)\n */\nexport function calcConfirmations(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n): number {\n if (!depositBlockHeight || !currentBlockHeight) {\n return 0;\n }\n // Deposit block height counts as the first confirmation\n return Math.max(0, currentBlockHeight - depositBlockHeight + 1);\n}\n\n/**\n * Get confirmation progress for a deposit\n *\n * @param currentBlockHeight - Current Bitcoin block height\n * @param depositBlockHeight - Block height where deposit was confirmed\n * @param requiredConfirmations - Number of confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns Confirmation progress info, or null if block heights unavailable\n */\nexport function getConfirmationProgress(\n currentBlockHeight?: number,\n depositBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): ConfirmationProgress | null {\n if (currentBlockHeight === undefined || depositBlockHeight === undefined) {\n return null;\n }\n\n const current = calcConfirmations(currentBlockHeight, depositBlockHeight);\n const percentage = Math.min(\n 100,\n Math.round((current / requiredConfirmations) * 100),\n );\n\n return {\n current,\n required: requiredConfirmations,\n percentage,\n isComplete: current >= requiredConfirmations,\n };\n}\n\n/**\n * Determine the status of a deposit\n *\n * Logic priority:\n * 1. Sanctioned → restricted\n * 2. Already claimed → claimed\n * 3. GMP handled → auto_claimed (definitive success, overrides expired/failed)\n * 4. Amount too small → too_small (permanent, re-auth won't help)\n * 5. Notarization failed → failed (terminal, overrides expired)\n * 6. Session expired → expired (recoverable via re-auth)\n * 7. Based on notarization status + proof availability:\n * - PENDING/SUBMITTED without enough confirmations → pending_confirmations\n * - PENDING/SUBMITTED with confirmations → pending_notarization\n * - SESSION_APPROVED with proof → claimable\n * - SESSION_APPROVED without proof → pending_notarization (edge case)\n *\n * @param deposit - The deposit object from the SDK\n * @param currentBlockHeight - Current BTC block height (optional, enhances accuracy)\n * @param requiredConfirmations - Confirmations required (default: REQUIRED_CONFIRMATIONS)\n * @returns The deposit status\n */\nexport function getDepositStatus(\n deposit: Deposit,\n currentBlockHeight?: number,\n requiredConfirmations: number = REQUIRED_CONFIRMATIONS,\n): DepositStatus {\n // 1. Check for sanctioned/restricted first\n if (deposit.sanctioned) {\n return 'restricted';\n }\n\n // 2. Check if already claimed\n if (deposit.isClaimed || deposit.claimTxHash) {\n return 'claimed';\n }\n\n // 3. Check for GMP auto-claim (definitive success, overrides expired/failed)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_GMP_HANDLED\n ) {\n return 'auto_claimed';\n }\n\n // 4. Check if amount is too small (permanent, re-auth won't help)\n const amountBtc = deposit.amount?.toNumber?.() ?? Number(deposit.amount);\n if (amountBtc > 0 && amountBtc < MIN_STAKE_AMOUNT_BTC) {\n return 'too_small';\n }\n\n // 5. Check for notarization failure (terminal, overrides expired)\n if (\n deposit.notarizationStatus ===\n ENotarizationStatus.NOTARIZATION_STATUS_FAILED\n ) {\n return 'failed';\n }\n\n // 6. Check if the notarization session has expired (recoverable via re-auth)\n if (deposit.sessionState === ESessionState.SESSION_STATE_EXPIRED) {\n return 'expired';\n }\n\n // 7. Determine status based on notarization status and proof availability\n const hasProof = !!deposit.proof && !!deposit.rawPayload;\n const notarizationStatus = deposit.notarizationStatus;\n\n // Check confirmations only if we have block height data\n const confirmations = calcConfirmations(\n currentBlockHeight,\n deposit.blockHeight,\n );\n const hasEnoughConfirmations =\n currentBlockHeight === undefined || confirmations >= requiredConfirmations;\n\n switch (notarizationStatus) {\n case ENotarizationStatus.NOTARIZATION_STATUS_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_GMP_PENDING:\n case ENotarizationStatus.NOTARIZATION_STATUS_SUBMITTED:\n // Still in notarization queue\n // If we know block height and not enough confirmations, show that\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n // Otherwise, we're waiting for notarization\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_SESSION_APPROVED:\n // Notarization approved\n if (hasProof) {\n return 'claimable';\n }\n // Edge case: approved but no proof yet (should be rare)\n return 'pending_notarization';\n\n case ENotarizationStatus.NOTARIZATION_STATUS_UNSPECIFIED:\n default:\n // Unknown status - check confirmations if we can\n if (currentBlockHeight !== undefined && !hasEnoughConfirmations) {\n return 'pending_confirmations';\n }\n return 'pending_notarization';\n }\n}\n\n/**\n * Get display configuration for a deposit status\n *\n * @param status - The deposit status\n * @returns Display configuration with label, severity, and description\n */\nexport function getDepositStatusDisplay(\n status: DepositStatus,\n): DepositStatusDisplay {\n switch (status) {\n case 'pending_confirmations':\n return {\n label: 'Pending Confirmations',\n severity: 'warning',\n description: `Waiting for Bitcoin block confirmations (${REQUIRED_CONFIRMATIONS} required)`,\n isTerminal: false,\n requiresAction: false,\n };\n case 'pending_notarization':\n return {\n label: 'Pending Notarization',\n severity: 'info',\n description:\n 'Confirmations complete, waiting for notarization service to generate proof',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimable':\n return {\n label: 'Claimable',\n severity: 'success',\n description: 'Ready to mint - proof available, claim to receive tokens',\n isTerminal: false,\n requiresAction: true,\n };\n case 'claiming':\n return {\n label: 'Claiming',\n severity: 'info',\n description: 'Claim transaction in progress',\n isTerminal: false,\n requiresAction: false,\n };\n case 'claimed':\n return {\n label: 'Claimed',\n severity: 'neutral',\n description: 'Tokens have been minted to your address',\n isTerminal: true,\n requiresAction: false,\n };\n case 'auto_claimed':\n return {\n label: 'Auto-Claimed',\n severity: 'success',\n description: 'Automatically claimed via cross-chain messaging (GMP)',\n isTerminal: true,\n requiresAction: false,\n };\n case 'expired':\n return {\n label: 'Expired',\n severity: 'error',\n description: 'Fee signature expired, requires re-authorization',\n isTerminal: false,\n requiresAction: true,\n };\n case 'failed':\n return {\n label: 'Failed',\n severity: 'error',\n description: 'Notarization failed - contact support',\n isTerminal: true,\n requiresAction: false,\n };\n case 'restricted':\n return {\n label: 'Restricted',\n severity: 'error',\n description: 'This deposit is restricted or sanctioned',\n isTerminal: true,\n requiresAction: false,\n };\n case 'too_small':\n return {\n label: 'Too Small',\n severity: 'neutral',\n description: `Amount below minimum claimable amount (${MIN_STAKE_AMOUNT_BTC} BTC)`,\n isTerminal: true,\n requiresAction: false,\n };\n }\n}\n\n// ═══════════════════════════════════════════════════════════════════════════\n// Helper Functions\n// ═══════════════════════════════════════════════════════════════════════════\n\n/**\n * Check if a deposit can be claimed manually\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if the deposit is in claimable state\n */\nexport function isDepositClaimable(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n return getDepositStatus(deposit, currentBlockHeight) === 'claimable';\n}\n\n/**\n * Check if a deposit is in a pending state (confirmations or notarization)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is pending\n */\nexport function isDepositPending(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n return (\n status === 'pending_confirmations' || status === 'pending_notarization'\n );\n}\n\n/**\n * Check if a deposit is in a terminal state (no further action possible)\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if deposit is in terminal state\n */\nexport function isDepositTerminal(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.isTerminal;\n}\n\n/**\n * Check if a deposit requires user action\n *\n * @param deposit - The deposit object\n * @param currentBlockHeight - Current BTC block height (optional)\n * @returns True if user action is required\n */\nexport function depositRequiresAction(\n deposit: Deposit,\n currentBlockHeight?: number,\n): boolean {\n const status = getDepositStatus(deposit, currentBlockHeight);\n const display = getDepositStatusDisplay(status);\n return display.requiresAction;\n}\n"],"names":["getLBTCExchangeRate","env","chainId","ChainId","amount","toSatoshi","baseApiUrl","getApiConfig","chainIdName","getChainNameById","data","axios","amountOut","BigNumber","exchangeRate","minAmount","MIN_STAKE_AMOUNT_BTC","URL","setReferral","address","signature","eip712Data","referrerCode","pubKey","requestParams","error","errorMsg","getErrorMessage","REQUIRED_CONFIRMATIONS","MIN_CLAIM_AMOUNT_BTC","calcConfirmations","currentBlockHeight","depositBlockHeight","getConfirmationProgress","requiredConfirmations","current","percentage","getDepositStatus","deposit","ENotarizationStatus","amountBtc","_b","_a","ESessionState","hasProof","notarizationStatus","confirmations","hasEnoughConfirmations","getDepositStatusDisplay","status","isDepositClaimable","isDepositPending","isDepositTerminal","depositRequiresAction"],"mappings":";;;;;;;;;AAwDA,eAAsBA,EAAoB;AAAA,EACxC,KAAAC;AAAA,EACA,SAAAC,IAAUC,EAAQ;AAAA,EAClB,QAAAC,IAASC,EAAU,CAAC;AACtB,GAAsE;AACpE,QAAM,EAAE,YAAAC,EAAA,IAAeC,EAAaN,CAAG,GACjCO,IAAcC,EAAiBP,CAAO,GAEtC,EAAE,MAAAQ,EAAA,IAAS,MAAMC,EAAM;AAAA,IAC3B,wBAAwBH,CAAW;AAAA,IACnC,EAAE,SAASF,GAAY,QAAQ,EAAE,QAAAF,IAAO;AAAA,EAAE,GAGtCQ,IAAYC,EAAUH,EAAK,UAAU,EAAE,SAAA,GACvCI,IAAeD,EAAUT,CAAM,EAAE,UAAUM,EAAK,UAAU,EAAE,SAAA,GAC5DK,IAAYV,EAAUW,CAAoB,EAAE,SAAA;AAElD,SAAO,EAAE,WAAAJ,GAAW,cAAAE,GAAc,WAAAC,EAAA;AACpC;ACpEA,MAAME,IAAM;AAiCZ,eAAsBC,EAAY;AAAA,EAChC,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,cAAAC;AAAA,EACA,QAAAC;AAAA,EACA,KAAAtB;AACF,GAAsC;AACpC,QAAM,EAAE,YAAAK,EAAA,IAAeC,EAAaN,CAAG,GAEjCuB,IAAgB;AAAA,I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A;AAAA,IAEpB,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,IAEpB,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,IAEpB,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,IAEpB,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,IAEpB,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,aAAa,0CAA0CZ,CAAoB;AAAA,QAC3E,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA;AAAA,EAClB;AAEN;AAaO,SAASkC,EACdZ,GACAP,GACS;AACT,SAAOM,EAAiBC,GAASP,CAAkB,MAAM;AAC3D;AASO,SAASoB,EACdb,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAC3D,SACEkB,MAAW,2BAA2BA,MAAW;AAErD;AASO,SAASG,EACdd,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAE3D,SADgBiB,EAAwBC,CAAM,EAC/B;AACjB;AASO,SAASI,EACdf,GACAP,GACS;AACT,QAAMkB,IAASZ,EAAiBC,GAASP,CAAkB;AAE3D,SADgBiB,EAAwBC,CAAM,EAC/B;AACjB;"}
|
|
@@ -2,18 +2,19 @@ var $ = Object.defineProperty;
|
|
|
2
2
|
var q = (s, t, e) => t in s ? $(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
3
|
var a = (s, t, e) => q(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import "axios";
|
|
5
|
-
import { SDK_RUNTIME as z, SDK_VERSION as W, LombardError as d, bitcoinAddressSchema as I, Chain as h, BaseAction as C, NonEvmOperationStatus as r, validatePrepareParams as f, StepStatus as o, objectType as E, amountSchema as A, solanaAddressSchema as w, CapabilityRegistry as S, PartnerConfiguration as _, getProviderGetter as D, ASSET_CATALOG as b, getAssetAddress as X, getAssetDecimals as Z, getAssetMetadata as J, usesAssetRouter as Q, getAssetRouter as tt, getBridgeAdapter as et, getPublicMarketMaker as st, getAssetByAddress as nt, isAssetDeployed as rt, getAssetChains as it, getAssetEnvironments as at, getSupportedAssets as ot, ProviderErrorCode as ct } from "./statusConstants-
|
|
6
|
-
import { generateDepositBtcAddress as ut } from "./getUserStakeAndBakeSignature-
|
|
7
|
-
import { getDepositsByAddress as O, getUnstakesByAddress as ht, getPointsByAddress as dt, getDepositBtcAddress as y, storeStakeAndBakeSignature as gt, ReferralsClient as lt } from "./ReferralsClient-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { SDK_RUNTIME as z, SDK_VERSION as W, LombardError as d, bitcoinAddressSchema as I, Chain as h, BaseAction as C, NonEvmOperationStatus as r, validatePrepareParams as f, StepStatus as o, objectType as E, amountSchema as A, solanaAddressSchema as w, CapabilityRegistry as S, PartnerConfiguration as _, getProviderGetter as D, ASSET_CATALOG as b, getAssetAddress as X, getAssetDecimals as Z, getAssetMetadata as J, usesAssetRouter as Q, getAssetRouter as tt, getBridgeAdapter as et, getPublicMarketMaker as st, getAssetByAddress as nt, isAssetDeployed as rt, getAssetChains as it, getAssetEnvironments as at, getSupportedAssets as ot, ProviderErrorCode as ct } from "./statusConstants-DLrd03gT.js";
|
|
6
|
+
import { generateDepositBtcAddress as ut } from "./getUserStakeAndBakeSignature-CQsvL79O.js";
|
|
7
|
+
import { getDepositsByAddress as O, getUnstakesByAddress as ht, getPointsByAddress as dt, getDepositBtcAddress as y, storeStakeAndBakeSignature as gt, ReferralsClient as lt } from "./ReferralsClient-BNwB6wO4.js";
|
|
8
|
+
import { getNetworkFeeSignature as pt } from "./getNetworkFeeSignature-FuDJWrMC.js";
|
|
9
|
+
import { storeNetworkFeeSignature as mt } from "./storeNetworkFeeSignature-sCt4_nHr.js";
|
|
10
|
+
import { btcModule as vt, BtcActions as Ct } from "./BtcActions-D7HekjRg.js";
|
|
11
|
+
import { evmModule as ft, EvmActions as Et } from "./EvmActions-nbR8cSa4.js";
|
|
11
12
|
import { SOLANA_DEVNET_CHAIN as At, SOLANA_MAINNET_CHAIN as It, getSolanaTokenAddress as L, Token as k } from "./token-addresses-DVnRPyu4.js";
|
|
12
13
|
import { toSatoshi as T } from "./satoshi-CSoJBXc6.js";
|
|
13
14
|
import { p as B, r as c } from "./index-CfcQ_g3t.js";
|
|
14
15
|
import { AssetId as g } from "./defi-registry-DULXbu3D.js";
|
|
15
16
|
import { getExchangeRatio as St } from "./get-exchange-ratio-BvPUfcIQ.js";
|
|
16
|
-
import { getEarnWithdrawals as _t, getEarnWithdrawalsAllChains as Dt } from "./get-vault-withdrawals-
|
|
17
|
+
import { getEarnWithdrawals as _t, getEarnWithdrawalsAllChains as Dt } from "./get-vault-withdrawals-BayGky8y.js";
|
|
17
18
|
const P = ["debug", "info", "warn", "error", "none"];
|
|
18
19
|
function Nt(s = {}) {
|
|
19
20
|
const {
|
|
@@ -42,7 +43,7 @@ function Nt(s = {}) {
|
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function pe() {
|
|
46
47
|
return {
|
|
47
48
|
debug: () => {
|
|
48
49
|
},
|
|
@@ -54,7 +55,7 @@ function le() {
|
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
+
function me() {
|
|
58
59
|
return {
|
|
59
60
|
"X-SDK-Version": W,
|
|
60
61
|
"X-SDK-Runtime": z
|
|
@@ -217,7 +218,8 @@ class Tt {
|
|
|
217
218
|
env: this.env
|
|
218
219
|
}) : Dt({
|
|
219
220
|
account: n,
|
|
220
|
-
rpcUrl: e == null ? void 0 : e.rpcUrl
|
|
221
|
+
rpcUrl: e == null ? void 0 : e.rpcUrl,
|
|
222
|
+
env: this.env
|
|
221
223
|
});
|
|
222
224
|
}
|
|
223
225
|
/* -------------------------------------------------------------------------- */
|
|
@@ -312,7 +314,7 @@ class wt {
|
|
|
312
314
|
* Store network fee signature
|
|
313
315
|
*/
|
|
314
316
|
async storeFeeSignature(t) {
|
|
315
|
-
await
|
|
317
|
+
await mt({
|
|
316
318
|
address: t.address,
|
|
317
319
|
signature: t.signature,
|
|
318
320
|
typedData: t.typedData,
|
|
@@ -324,7 +326,7 @@ class wt {
|
|
|
324
326
|
* Get stored network fee signature
|
|
325
327
|
*/
|
|
326
328
|
async getFeeSignature(t) {
|
|
327
|
-
return
|
|
329
|
+
return pt({
|
|
328
330
|
address: t.address,
|
|
329
331
|
chainId: t.chainId,
|
|
330
332
|
env: this.env,
|
|
@@ -782,7 +784,7 @@ class G {
|
|
|
782
784
|
return new Mt(this.ctx, t);
|
|
783
785
|
}
|
|
784
786
|
}
|
|
785
|
-
function
|
|
787
|
+
function ve(s) {
|
|
786
788
|
return new G(s);
|
|
787
789
|
}
|
|
788
790
|
const U = {
|
|
@@ -899,7 +901,7 @@ class K {
|
|
|
899
901
|
return new Vt(this.ctx, t);
|
|
900
902
|
}
|
|
901
903
|
}
|
|
902
|
-
function
|
|
904
|
+
function Ce(s) {
|
|
903
905
|
return new K(s);
|
|
904
906
|
}
|
|
905
907
|
const V = {
|
|
@@ -1027,7 +1029,7 @@ class j {
|
|
|
1027
1029
|
return new zt(this.ctx, t);
|
|
1028
1030
|
}
|
|
1029
1031
|
}
|
|
1030
|
-
function
|
|
1032
|
+
function fe(s) {
|
|
1031
1033
|
return new j(s);
|
|
1032
1034
|
}
|
|
1033
1035
|
class Xt {
|
|
@@ -1179,29 +1181,29 @@ const N = /* @__PURE__ */ new Map();
|
|
|
1179
1181
|
function Jt(s) {
|
|
1180
1182
|
return N.has(s) || N.set(s, Promise.resolve(b)), N.get(s);
|
|
1181
1183
|
}
|
|
1182
|
-
async function
|
|
1184
|
+
async function Ee(s) {
|
|
1183
1185
|
const t = "modules" in s && Array.isArray(s.modules) ? s : kt(s), e = await Jt(t.env), n = {
|
|
1184
1186
|
...t,
|
|
1185
1187
|
catalog: e
|
|
1186
1188
|
};
|
|
1187
1189
|
return new Zt(n);
|
|
1188
1190
|
}
|
|
1189
|
-
function
|
|
1191
|
+
function Ae(s) {
|
|
1190
1192
|
return typeof s == "object" && s !== null && "request" in s && typeof s.request == "function";
|
|
1191
1193
|
}
|
|
1192
|
-
function
|
|
1194
|
+
function Ie(s) {
|
|
1193
1195
|
return typeof s == "object" && s !== null && "getAddresses" in s && typeof s.getAddresses == "function";
|
|
1194
1196
|
}
|
|
1195
|
-
function
|
|
1197
|
+
function Se(s) {
|
|
1196
1198
|
return typeof s == "object" && s !== null && "publicKey" in s && "signAndSendTransaction" in s;
|
|
1197
1199
|
}
|
|
1198
|
-
function
|
|
1200
|
+
function _e(s) {
|
|
1199
1201
|
return typeof s == "object" && s !== null && "getAddress" in s && "signAndExecuteTransactionBlock" in s;
|
|
1200
1202
|
}
|
|
1201
|
-
function
|
|
1203
|
+
function De(s) {
|
|
1202
1204
|
return typeof s == "object" && s !== null && "address" in s && "execute" in s;
|
|
1203
1205
|
}
|
|
1204
|
-
const
|
|
1206
|
+
const Ne = {
|
|
1205
1207
|
/** Progress update with detailed step information */
|
|
1206
1208
|
Progress: "progress",
|
|
1207
1209
|
/** Status change (e.g., 'idle' → 'preparing' → 'ready') */
|
|
@@ -1212,31 +1214,31 @@ const De = {
|
|
|
1212
1214
|
Failed: "failed",
|
|
1213
1215
|
/** Error occurred */
|
|
1214
1216
|
Error: "error"
|
|
1215
|
-
},
|
|
1217
|
+
}, Te = {
|
|
1216
1218
|
Progress: "progress",
|
|
1217
1219
|
StatusChange: "status-change",
|
|
1218
1220
|
Completed: "completed",
|
|
1219
1221
|
Failed: "failed",
|
|
1220
1222
|
Error: "error"
|
|
1221
|
-
},
|
|
1223
|
+
}, xe = {
|
|
1222
1224
|
Progress: "progress",
|
|
1223
1225
|
StatusChange: "status-change",
|
|
1224
1226
|
Completed: "completed",
|
|
1225
1227
|
Failed: "failed",
|
|
1226
1228
|
Error: "error"
|
|
1227
|
-
},
|
|
1229
|
+
}, Pe = {
|
|
1228
1230
|
Progress: "progress",
|
|
1229
1231
|
StatusChange: "status-change",
|
|
1230
1232
|
Completed: "completed",
|
|
1231
1233
|
Failed: "failed",
|
|
1232
1234
|
Error: "error"
|
|
1233
|
-
},
|
|
1235
|
+
}, we = {
|
|
1234
1236
|
Progress: "progress",
|
|
1235
1237
|
StatusChange: "status-change",
|
|
1236
1238
|
Completed: "completed",
|
|
1237
1239
|
Failed: "failed",
|
|
1238
1240
|
Error: "error"
|
|
1239
|
-
},
|
|
1241
|
+
}, be = {
|
|
1240
1242
|
Progress: "progress",
|
|
1241
1243
|
StatusChange: "status-change",
|
|
1242
1244
|
Completed: "completed",
|
|
@@ -1245,28 +1247,28 @@ const De = {
|
|
|
1245
1247
|
};
|
|
1246
1248
|
export {
|
|
1247
1249
|
Tt as ApiNamespace,
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1250
|
+
be as BridgeEvent,
|
|
1251
|
+
we as DeployEvent,
|
|
1252
|
+
Te as DepositEvent,
|
|
1251
1253
|
Zt as LombardSDK,
|
|
1252
|
-
|
|
1254
|
+
xe as RedeemEvent,
|
|
1253
1255
|
G as SolanaActions,
|
|
1254
|
-
|
|
1256
|
+
Ne as StakeEvent,
|
|
1255
1257
|
K as StarknetActions,
|
|
1256
1258
|
j as SuiActions,
|
|
1257
|
-
|
|
1259
|
+
Pe as UnstakeEvent,
|
|
1258
1260
|
kt as createConfig,
|
|
1259
1261
|
Nt as createConsoleLogger,
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1262
|
+
Ee as createLombardSDK,
|
|
1263
|
+
pe as createSilentLogger,
|
|
1264
|
+
me as getSdkHeaders,
|
|
1265
|
+
Ie as isBtcProvider,
|
|
1266
|
+
Ae as isEvmProvider,
|
|
1267
|
+
Se as isSolanaProvider,
|
|
1268
|
+
De as isStarknetProvider,
|
|
1269
|
+
_e as isSuiProvider,
|
|
1270
|
+
ve as solanaActions,
|
|
1271
|
+
Ce as starknetActions,
|
|
1272
|
+
fe as suiActions
|
|
1271
1273
|
};
|
|
1272
|
-
//# sourceMappingURL=events-
|
|
1274
|
+
//# sourceMappingURL=events-BP_Ahnsm.js.map
|