@lombard.finance/sdk 5.0.5 → 5.1.0-canary-2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/api-functions/index.d.ts +1 -0
  3. package/dist/api-functions/index.d.ts.map +1 -1
  4. package/dist/api-functions/walletAuth/index.d.ts +4 -0
  5. package/dist/api-functions/walletAuth/index.d.ts.map +1 -0
  6. package/dist/api-functions/walletAuth/requestWalletChallenge.d.ts +13 -0
  7. package/dist/api-functions/walletAuth/requestWalletChallenge.d.ts.map +1 -0
  8. package/dist/api-functions/walletAuth/revokeWalletToken.d.ts +15 -0
  9. package/dist/api-functions/walletAuth/revokeWalletToken.d.ts.map +1 -0
  10. package/dist/api-functions/walletAuth/verifyWalletSignature.d.ts +17 -0
  11. package/dist/api-functions/walletAuth/verifyWalletSignature.d.ts.map +1 -0
  12. package/dist/api.cjs +1 -1
  13. package/dist/api.js +6 -6
  14. package/dist/bridge.cjs +1 -1
  15. package/dist/bridge.js +1 -1
  16. package/dist/btc.cjs +1 -1
  17. package/dist/btc.js +2 -2
  18. package/dist/chunks/{BtcActions-DZs5eXTb.cjs → BtcActions-CaoeJtse.cjs} +2 -2
  19. package/dist/chunks/{BtcActions-DZs5eXTb.cjs.map → BtcActions-CaoeJtse.cjs.map} +1 -1
  20. package/dist/chunks/{BtcActions-BDTnGE1D.js → BtcActions-D7N6pivv.js} +5 -5
  21. package/dist/chunks/{BtcActions-BDTnGE1D.js.map → BtcActions-D7N6pivv.js.map} +1 -1
  22. package/dist/chunks/{EvmActions-8VeTiWrl.js → EvmActions-DPu4lBNV.js} +6 -6
  23. package/dist/chunks/{EvmActions-8VeTiWrl.js.map → EvmActions-DPu4lBNV.js.map} +1 -1
  24. package/dist/chunks/{EvmActions-CEC3vNtR.cjs → EvmActions-DeZdPzqb.cjs} +2 -2
  25. package/dist/chunks/{EvmActions-CEC3vNtR.cjs.map → EvmActions-DeZdPzqb.cjs.map} +1 -1
  26. package/dist/chunks/{ReferralsClient-BNwB6wO4.js → ReferralsClient-CM2YjtPf.js} +3 -3
  27. package/dist/chunks/{ReferralsClient-BNwB6wO4.js.map → ReferralsClient-CM2YjtPf.js.map} +1 -1
  28. package/dist/chunks/{ReferralsClient-B65Nsk21.cjs → ReferralsClient-CShlPUSW.cjs} +2 -2
  29. package/dist/chunks/{ReferralsClient-B65Nsk21.cjs.map → ReferralsClient-CShlPUSW.cjs.map} +1 -1
  30. package/dist/chunks/{api-config-Dm6dR85f.js → api-config-qafx1EcJ.js} +17 -11
  31. package/dist/chunks/api-config-qafx1EcJ.js.map +1 -0
  32. package/dist/chunks/api-config-rSZXrhIj.cjs +2 -0
  33. package/dist/chunks/api-config-rSZXrhIj.cjs.map +1 -0
  34. package/dist/chunks/{approveLBTC-B1QepkpF.cjs → approveLBTC-D9TTk9Le.cjs} +2 -2
  35. package/dist/chunks/{approveLBTC-B1QepkpF.cjs.map → approveLBTC-D9TTk9Le.cjs.map} +1 -1
  36. package/dist/chunks/{approveLBTC-BFhW5cPX.js → approveLBTC-DL-jyaLI.js} +2 -2
  37. package/dist/chunks/{approveLBTC-BFhW5cPX.js.map → approveLBTC-DL-jyaLI.js.map} +1 -1
  38. package/dist/chunks/{bridge-CQmXrRKS.cjs → bridge-CnEVkvXU.cjs} +2 -2
  39. package/dist/chunks/{bridge-CQmXrRKS.cjs.map → bridge-CnEVkvXU.cjs.map} +1 -1
  40. package/dist/chunks/{bridge-DnDIoRdh.js → bridge-E90jjF8n.js} +3 -3
  41. package/dist/chunks/{bridge-DnDIoRdh.js.map → bridge-E90jjF8n.js.map} +1 -1
  42. package/dist/chunks/{depositStatus-DUXMloTa.cjs → depositStatus-JoMTz_wm.cjs} +2 -2
  43. package/dist/chunks/{depositStatus-DUXMloTa.cjs.map → depositStatus-JoMTz_wm.cjs.map} +1 -1
  44. package/dist/chunks/{depositStatus-hmXphYhu.js → depositStatus-xVBInKTX.js} +5 -5
  45. package/dist/chunks/{depositStatus-hmXphYhu.js.map → depositStatus-xVBInKTX.js.map} +1 -1
  46. package/dist/chunks/{events-CW_OMnKf.cjs → events-D7Njgkja.cjs} +2 -2
  47. package/dist/chunks/{events-CW_OMnKf.cjs.map → events-D7Njgkja.cjs.map} +1 -1
  48. package/dist/chunks/{events-22AhTtaL.js → events-gWA_-EJq.js} +10 -10
  49. package/dist/chunks/{events-22AhTtaL.js.map → events-gWA_-EJq.js.map} +1 -1
  50. package/dist/chunks/{evm-by-btc-address-DiQoIWsr.cjs → evm-by-btc-address-D4aIJscb.cjs} +2 -2
  51. package/dist/chunks/{evm-by-btc-address-DiQoIWsr.cjs.map → evm-by-btc-address-D4aIJscb.cjs.map} +1 -1
  52. package/dist/chunks/{evm-by-btc-address-CZvE15lx.js → evm-by-btc-address-qUQp5qH5.js} +2 -2
  53. package/dist/chunks/{evm-by-btc-address-CZvE15lx.js.map → evm-by-btc-address-qUQp5qH5.js.map} +1 -1
  54. package/dist/chunks/{get-exchange-ratio-DGztGO7i.cjs → get-exchange-ratio-BJcnKt9w.cjs} +2 -2
  55. package/dist/chunks/{get-exchange-ratio-DGztGO7i.cjs.map → get-exchange-ratio-BJcnKt9w.cjs.map} +1 -1
  56. package/dist/chunks/{get-exchange-ratio-BvPUfcIQ.js → get-exchange-ratio-O4BrIkv0.js} +2 -2
  57. package/dist/chunks/{get-exchange-ratio-BvPUfcIQ.js.map → get-exchange-ratio-O4BrIkv0.js.map} +1 -1
  58. package/dist/chunks/{get-positions-summary-CC7BDtlY.cjs → get-positions-summary-CHIo_aQ_.cjs} +2 -2
  59. package/dist/chunks/{get-positions-summary-CC7BDtlY.cjs.map → get-positions-summary-CHIo_aQ_.cjs.map} +1 -1
  60. package/dist/chunks/{get-positions-summary-DxAgmaMl.js → get-positions-summary-yrhIZzHN.js} +2 -2
  61. package/dist/chunks/{get-positions-summary-DxAgmaMl.js.map → get-positions-summary-yrhIZzHN.js.map} +1 -1
  62. package/dist/chunks/{get-vault-tvl-CweOpdGy.js → get-vault-tvl-CoVm7ws5.js} +3 -3
  63. package/dist/chunks/{get-vault-tvl-CweOpdGy.js.map → get-vault-tvl-CoVm7ws5.js.map} +1 -1
  64. package/dist/chunks/{get-vault-tvl-vH_D4tu0.cjs → get-vault-tvl-DC7ZGp85.cjs} +2 -2
  65. package/dist/chunks/{get-vault-tvl-vH_D4tu0.cjs.map → get-vault-tvl-DC7ZGp85.cjs.map} +1 -1
  66. package/dist/chunks/{get-vault-withdrawals-GHCAh3wp.cjs → get-vault-withdrawals-Dk33seBn.cjs} +2 -2
  67. package/dist/chunks/{get-vault-withdrawals-GHCAh3wp.cjs.map → get-vault-withdrawals-Dk33seBn.cjs.map} +1 -1
  68. package/dist/chunks/{get-vault-withdrawals-BayGky8y.js → get-vault-withdrawals-vrs7as_9.js} +3 -3
  69. package/dist/chunks/{get-vault-withdrawals-BayGky8y.js.map → get-vault-withdrawals-vrs7as_9.js.map} +1 -1
  70. package/dist/chunks/{getNetworkFeeSignature-FuDJWrMC.js → getNetworkFeeSignature-DVY1Dlh-.js} +3 -3
  71. package/dist/chunks/{getNetworkFeeSignature-FuDJWrMC.js.map → getNetworkFeeSignature-DVY1Dlh-.js.map} +1 -1
  72. package/dist/chunks/{getNetworkFeeSignature-DqKLslZc.cjs → getNetworkFeeSignature-D_Da-ro1.cjs} +2 -2
  73. package/dist/chunks/{getNetworkFeeSignature-DqKLslZc.cjs.map → getNetworkFeeSignature-D_Da-ro1.cjs.map} +1 -1
  74. package/dist/chunks/{getUserStakeAndBakeSignature-CQsvL79O.js → getUserStakeAndBakeSignature-Dvrkir30.js} +3 -3
  75. package/dist/chunks/{getUserStakeAndBakeSignature-CQsvL79O.js.map → getUserStakeAndBakeSignature-Dvrkir30.js.map} +1 -1
  76. package/dist/chunks/{getUserStakeAndBakeSignature-Cwwx89pR.cjs → getUserStakeAndBakeSignature-MAvUVkKD.cjs} +2 -2
  77. package/dist/chunks/{getUserStakeAndBakeSignature-Cwwx89pR.cjs.map → getUserStakeAndBakeSignature-MAvUVkKD.cjs.map} +1 -1
  78. package/dist/chunks/{statusConstants-DZlImWu7.js → statusConstants-CC4bJf0C.js} +3 -3
  79. package/dist/chunks/{statusConstants-DZlImWu7.js.map → statusConstants-CC4bJf0C.js.map} +1 -1
  80. package/dist/chunks/statusConstants-D8Rb7g7_.cjs +2 -0
  81. package/dist/chunks/{statusConstants-Cz77HXnT.cjs.map → statusConstants-D8Rb7g7_.cjs.map} +1 -1
  82. package/dist/chunks/{storeNetworkFeeSignature-sCt4_nHr.js → storeNetworkFeeSignature-9YVYoLyK.js} +3 -3
  83. package/dist/chunks/{storeNetworkFeeSignature-sCt4_nHr.js.map → storeNetworkFeeSignature-9YVYoLyK.js.map} +1 -1
  84. package/dist/chunks/{storeNetworkFeeSignature-BaG3AU8U.cjs → storeNetworkFeeSignature-BHlqcnfa.cjs} +2 -2
  85. package/dist/chunks/{storeNetworkFeeSignature-BaG3AU8U.cjs.map → storeNetworkFeeSignature-BHlqcnfa.cjs.map} +1 -1
  86. package/dist/chunks/{tokens-C5rzCTTM.cjs → tokens-Di3O7wcg.cjs} +2 -2
  87. package/dist/chunks/{tokens-C5rzCTTM.cjs.map → tokens-Di3O7wcg.cjs.map} +1 -1
  88. package/dist/chunks/{tokens-BUrC15ra.js → tokens-DuE0oU7o.js} +2 -2
  89. package/dist/chunks/{tokens-BUrC15ra.js.map → tokens-DuE0oU7o.js.map} +1 -1
  90. package/dist/chunks/{unwrapBtceToLbtcv-BL5bF9y2.js → unwrapBtceToLbtcv-ByqIIQ30.js} +3 -3
  91. package/dist/chunks/{unwrapBtceToLbtcv-BL5bF9y2.js.map → unwrapBtceToLbtcv-ByqIIQ30.js.map} +1 -1
  92. package/dist/chunks/{unwrapBtceToLbtcv-Chc_QObp.cjs → unwrapBtceToLbtcv-Dvn_SrVP.cjs} +2 -2
  93. package/dist/chunks/{unwrapBtceToLbtcv-Chc_QObp.cjs.map → unwrapBtceToLbtcv-Dvn_SrVP.cjs.map} +1 -1
  94. package/dist/chunks/{withdrawEarn-BM_JOe4k.js → withdrawEarn-CmpiINKQ.js} +3 -3
  95. package/dist/chunks/{withdrawEarn-BM_JOe4k.js.map → withdrawEarn-CmpiINKQ.js.map} +1 -1
  96. package/dist/chunks/{withdrawEarn-CXfCmXJl.cjs → withdrawEarn-DTRkg9QM.cjs} +2 -2
  97. package/dist/chunks/{withdrawEarn-CXfCmXJl.cjs.map → withdrawEarn-DTRkg9QM.cjs.map} +1 -1
  98. package/dist/common/api-config.d.ts +9 -0
  99. package/dist/common/api-config.d.ts.map +1 -1
  100. package/dist/contracts.cjs +1 -1
  101. package/dist/contracts.js +3 -3
  102. package/dist/core.cjs +1 -1
  103. package/dist/core.js +6 -6
  104. package/dist/debug.cjs +1 -1
  105. package/dist/debug.js +1 -1
  106. package/dist/entries/strategies.d.ts +11 -0
  107. package/dist/entries/strategies.d.ts.map +1 -0
  108. package/dist/evm.cjs +1 -1
  109. package/dist/evm.js +3 -3
  110. package/dist/index.cjs +1 -1
  111. package/dist/index.cjs.map +1 -1
  112. package/dist/index.d.ts +3 -0
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +408 -303
  115. package/dist/index.js.map +1 -1
  116. package/dist/metrics.cjs +1 -1
  117. package/dist/metrics.js +1 -1
  118. package/dist/modules/index.d.ts +3 -1
  119. package/dist/modules/index.d.ts.map +1 -1
  120. package/dist/modules/walletAuthModule.d.ts +32 -0
  121. package/dist/modules/walletAuthModule.d.ts.map +1 -0
  122. package/dist/services/WalletAuthService.d.ts +18 -0
  123. package/dist/services/WalletAuthService.d.ts.map +1 -0
  124. package/dist/services/index.d.ts +2 -1
  125. package/dist/services/index.d.ts.map +1 -1
  126. package/dist/strategies/index.d.ts +19 -0
  127. package/dist/strategies/index.d.ts.map +1 -0
  128. package/dist/strategies/lib/config/index.d.ts +15 -0
  129. package/dist/strategies/lib/config/index.d.ts.map +1 -0
  130. package/dist/strategies/lib/config/registry.d.ts +67 -0
  131. package/dist/strategies/lib/config/registry.d.ts.map +1 -0
  132. package/dist/strategies/lib/config/strategies/btcoc.d.ts +18 -0
  133. package/dist/strategies/lib/config/strategies/btcoc.d.ts.map +1 -0
  134. package/dist/strategies/lib/config/types.d.ts +49 -0
  135. package/dist/strategies/lib/config/types.d.ts.map +1 -0
  136. package/dist/strategies/lib/metrics/getStrategyNavHistory.d.ts +30 -0
  137. package/dist/strategies/lib/metrics/getStrategyNavHistory.d.ts.map +1 -0
  138. package/dist/strategies/lib/metrics/getStrategyRatesHistory.d.ts +27 -0
  139. package/dist/strategies/lib/metrics/getStrategyRatesHistory.d.ts.map +1 -0
  140. package/dist/strategies/lib/metrics/getStrategyState.d.ts +13 -0
  141. package/dist/strategies/lib/metrics/getStrategyState.d.ts.map +1 -0
  142. package/dist/strategies/lib/metrics/getUserActivityFeed.d.ts +22 -0
  143. package/dist/strategies/lib/metrics/getUserActivityFeed.d.ts.map +1 -0
  144. package/dist/strategies/lib/metrics/getUserPosition.d.ts +14 -0
  145. package/dist/strategies/lib/metrics/getUserPosition.d.ts.map +1 -0
  146. package/dist/strategies/lib/metrics/getUserPositionHistory.d.ts +18 -0
  147. package/dist/strategies/lib/metrics/getUserPositionHistory.d.ts.map +1 -0
  148. package/dist/strategies/lib/metrics/getUserWithdrawals.d.ts +13 -0
  149. package/dist/strategies/lib/metrics/getUserWithdrawals.d.ts.map +1 -0
  150. package/dist/strategies/lib/metrics/userEndpoints.d.ts +50 -0
  151. package/dist/strategies/lib/metrics/userEndpoints.d.ts.map +1 -0
  152. package/dist/strategies/lib/ops/depositStrategy.d.ts +44 -0
  153. package/dist/strategies/lib/ops/depositStrategy.d.ts.map +1 -0
  154. package/dist/strategies/lib/ops/getStrategyDepositAssets.d.ts +22 -0
  155. package/dist/strategies/lib/ops/getStrategyDepositAssets.d.ts.map +1 -0
  156. package/dist/strategies/lib/ops/getStrategyPendingRedeem.d.ts +15 -0
  157. package/dist/strategies/lib/ops/getStrategyPendingRedeem.d.ts.map +1 -0
  158. package/dist/strategies/lib/ops/getStrategyPosition.d.ts +14 -0
  159. package/dist/strategies/lib/ops/getStrategyPosition.d.ts.map +1 -0
  160. package/dist/strategies/lib/ops/getStrategyShards.d.ts +11 -0
  161. package/dist/strategies/lib/ops/getStrategyShards.d.ts.map +1 -0
  162. package/dist/strategies/lib/ops/previewStrategyDeposit.d.ts +29 -0
  163. package/dist/strategies/lib/ops/previewStrategyDeposit.d.ts.map +1 -0
  164. package/dist/strategies/lib/ops/requestStrategyRedeem.d.ts +57 -0
  165. package/dist/strategies/lib/ops/requestStrategyRedeem.d.ts.map +1 -0
  166. package/dist/strategies/lib/params.d.ts +44 -0
  167. package/dist/strategies/lib/params.d.ts.map +1 -0
  168. package/dist/strategies/lib/types.d.ts +283 -0
  169. package/dist/strategies/lib/types.d.ts.map +1 -0
  170. package/dist/strategies.cjs +2 -0
  171. package/dist/strategies.cjs.map +1 -0
  172. package/dist/strategies.js +737 -0
  173. package/dist/strategies.js.map +1 -0
  174. package/dist/utils.cjs +1 -1
  175. package/dist/utils.js +2 -2
  176. package/dist/vaults.cjs +1 -1
  177. package/dist/vaults.js +3 -3
  178. package/package.json +10 -2
  179. package/dist/chunks/api-config-DkXqqfCK.cjs +0 -2
  180. package/dist/chunks/api-config-DkXqqfCK.cjs.map +0 -1
  181. package/dist/chunks/api-config-Dm6dR85f.js.map +0 -1
  182. package/dist/chunks/statusConstants-Cz77HXnT.cjs +0 -2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # 5.1.0
2
+
3
+ ### Added
4
+
5
+ - Wallet authentication module (`walletAuthModule`) implementing the v2 wallet-auth flow. Three endpoints are wrapped:
6
+ - `requestChallenge` → `POST /v2/auth/wallet/challenge` — returns a chain-specific payload to be signed by the user's wallet.
7
+ - `verifySignature` → `POST /v2/auth/wallet/verify` — exchanges a signed payload for a JWT. Accepts an optional `publicKey` for chains where pubkey is not recoverable from the signature (Starknet, Cosmos).
8
+ - `revokeToken` → `POST /v2/auth/token/revoke` — invalidates a JWT server-side; best-effort (swallows network errors so callers can always clear local state).
9
+ - Low-level functional exports for the same endpoints — `requestWalletChallenge`, `verifyWalletSignature`, `revokeWalletToken` — for consumers that don't want the module/DI layer.
10
+ - `WalletAuthService` class implementing the `WalletAuthService` interface from `@lombard.finance/sdk-common`.
11
+ - Signing the challenge with the user's wallet is intentionally NOT included — signing is chain-specific and belongs in the corresponding chain SDK package (or the consuming app).
12
+ - New `@lombard.finance/sdk/strategies` entry point for the Lombard DeFi Vault Strategy contract (codename "BTCoc"). Distinct from the Bitcoin Earn vault exposed under `@lombard.finance/sdk/vaults` — do not conflate the two. Env-first: a call picks a strategy (`strategyId`, default BTCoc) and an environment (`env`), and the chain follows from that pair — `prod` → Ethereum mainnet, `stage` → Base Sepolia. An env may host several per-chain deployments (each with its own contract address); an optional `chainId` selects among them and defaults to the primary (first) chain.
13
+ - Per-user / op reads: `getStrategyPosition`, `getStrategyDepositAssets`, `getStrategyPendingRedeem`, `getStrategyShards`, `previewStrategyDeposit`.
14
+ - Writes: `depositStrategy` (4-arg `deposit(asset, amount, receiver, minSharesOut)`, approves the Strategy contract on insufficient allowance), `requestStrategyRedeem` (async redeem; parses `requestId` from the `RedeemRequested` event, supports `waitForReceipt: false` for Safe multisig flows).
15
+ - Types: `IStrategyState`, `IStrategyPosition`, `IStrategyConfigResponse`, `IStrategyDepositAsset`, `IStrategyDepositAssetStatic`, `IStrategyShards`, `IStrategyPendingRedeem`, `IRequestStrategyRedeemResult`, plus function-parameter types (`GetStrategy*Parameters`, `DepositStrategyParameters`, `RequestStrategyRedeemParameters`).
16
+ - Config: `STRATEGIES` registry + `DEFAULT_STRATEGY_ID`, resolvers `resolveStrategy` / `getStrategyDeployment` / `getStrategyDeployments` / `getStrategyChainIds` / `getStrategyDefinition`, and `findStaticDepositAsset`. Each strategy maps every environment to a list of per-chain deployments — each deployment carries its own `chainId`, contract address, and static deposit-asset catalog (LBTC / BTC.b on Ethereum, LBTC / BTC.b / USDT / wETH / BTCt on Base Sepolia).
17
+
18
+ ---
19
+
1
20
  # 5.0.5
2
21
 
3
22
  ### Fixed
@@ -9,4 +9,5 @@ export * from './getUserStakeAndBakeSignature';
9
9
  export * from './setReferral';
10
10
  export * from './storeNetworkFeeSignature';
11
11
  export * from './storeStakeAndBakeSignature';
12
+ export * from './walletAuth';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api-functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api-functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './requestWalletChallenge';
2
+ export * from './revokeWalletToken';
3
+ export * from './verifyWalletSignature';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api-functions/walletAuth/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { WalletAuthChain, WalletChallengeResponse } from '@lombard.finance/sdk-common';
2
+ import { IEnvParam } from '../../common/parameters';
3
+ export interface RequestWalletChallengeParams extends IEnvParam {
4
+ address: string;
5
+ chain: WalletAuthChain;
6
+ }
7
+ /**
8
+ * Request a wallet challenge payload.
9
+ *
10
+ * POST /v2/auth/wallet/challenge
11
+ */
12
+ export declare function requestWalletChallenge({ address, chain, env, }: RequestWalletChallengeParams): Promise<WalletChallengeResponse>;
13
+ //# sourceMappingURL=requestWalletChallenge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestWalletChallenge.d.ts","sourceRoot":"","sources":["../../../src/api-functions/walletAuth/requestWalletChallenge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACxB,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AASpD,MAAM,WAAW,4BAA6B,SAAQ,SAAS;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,eAAe,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,EAC3C,OAAO,EACP,KAAK,EACL,GAAG,GACJ,EAAE,4BAA4B,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAqBjE"}
@@ -0,0 +1,15 @@
1
+ import { IEnvParam } from '../../common/parameters';
2
+ export interface RevokeWalletTokenParams extends IEnvParam {
3
+ /** JWT to invalidate server-side. */
4
+ jwt: string;
5
+ }
6
+ /**
7
+ * Revoke a wallet JWT server-side.
8
+ *
9
+ * POST /v2/auth/token/revoke (Authorization: Bearer <jwt>)
10
+ *
11
+ * Best-effort: network/server errors are swallowed so callers can always
12
+ * clear local state after a disconnect.
13
+ */
14
+ export declare function revokeWalletToken({ jwt, env, }: RevokeWalletTokenParams): Promise<void>;
15
+ //# sourceMappingURL=revokeWalletToken.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revokeWalletToken.d.ts","sourceRoot":"","sources":["../../../src/api-functions/walletAuth/revokeWalletToken.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,MAAM,WAAW,uBAAwB,SAAQ,SAAS;IACxD,qCAAqC;IACrC,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,GAAG,EACH,GAAG,GACJ,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBzC"}
@@ -0,0 +1,17 @@
1
+ import type { WalletAuthChain, WalletVerifyResponse } from '@lombard.finance/sdk-common';
2
+ import { IEnvParam } from '../../common/parameters';
3
+ export interface VerifyWalletSignatureParams extends IEnvParam {
4
+ address: string;
5
+ payload: string;
6
+ signature: string;
7
+ chain: WalletAuthChain;
8
+ /** Required for chains that don't expose pubkey in the signature (Starknet, Cosmos). */
9
+ publicKey?: string;
10
+ }
11
+ /**
12
+ * Verify a signed wallet challenge and obtain a JWT.
13
+ *
14
+ * POST /v2/auth/wallet/verify
15
+ */
16
+ export declare function verifyWalletSignature({ address, payload, signature, chain, publicKey, env, }: VerifyWalletSignatureParams): Promise<WalletVerifyResponse>;
17
+ //# sourceMappingURL=verifyWalletSignature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verifyWalletSignature.d.ts","sourceRoot":"","sources":["../../../src/api-functions/walletAuth/verifyWalletSignature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAQpD,MAAM,WAAW,2BAA4B,SAAQ,SAAS;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,eAAe,CAAC;IACvB,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,OAAO,EACP,OAAO,EACP,SAAS,EACT,KAAK,EACL,SAAS,EACT,GAAG,GACJ,EAAE,2BAA2B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0B7D"}
package/dist/api.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/ReferralsClient-B65Nsk21.cjs"),s=require("./chunks/getUserStakeAndBakeSignature-Cwwx89pR.cjs"),i=require("./chunks/get-exchange-ratio-DGztGO7i.cjs"),t=require("./chunks/depositStatus-DUXMloTa.cjs"),r=require("./chunks/getNetworkFeeSignature-DqKLslZc.cjs"),a=require("./chunks/storeNetworkFeeSignature-BaG3AU8U.cjs");exports.ENotarizationStatus=e.ENotarizationStatus;exports.ESessionState=e.ESessionState;exports.PayoutTxStatus=e.PayoutTxStatus;exports.ReferralsClient=e.ReferralsClient;exports.fetchBTCbDeposits=e.fetchBTCbDeposits;exports.fetchDirectDeposits=e.fetchDirectDeposits;exports.fetchUnstakesByAddress=e.fetchUnstakesByAddress;exports.getDepositBtcAddress=e.getDepositBtcAddress;exports.getDepositBtcAddresses=e.getDepositBtcAddresses;exports.getDepositsByAddress=e.getDepositsByAddress;exports.getLuxSeason1Points=e.getLuxSeason1Points;exports.getLuxSeason2Points=e.getLuxSeason2Points;exports.getPointsByAddress=e.getPointsByAddress;exports.getUnstakesByAddress=e.getUnstakesByAddress;exports.storeStakeAndBakeSignature=e.storeStakeAndBakeSignature;exports.SANCTIONED_ADDRESS=s.SANCTIONED_ADDRESS;exports.generateDepositBtcAddress=s.generateDepositBtcAddress;exports.getUserStakeAndBakeSignature=s.getUserStakeAndBakeSignature;exports.getExchangeRatio=i.getExchangeRatio;exports.MIN_CLAIM_AMOUNT_BTC=t.MIN_CLAIM_AMOUNT_BTC;exports.REQUIRED_CONFIRMATIONS=t.REQUIRED_CONFIRMATIONS;exports.calcConfirmations=t.calcConfirmations;exports.depositRequiresAction=t.depositRequiresAction;exports.getConfirmationProgress=t.getConfirmationProgress;exports.getDepositStatus=t.getDepositStatus;exports.getDepositStatusDisplay=t.getDepositStatusDisplay;exports.getLBTCExchangeRate=t.getLBTCExchangeRate;exports.isDepositClaimable=t.isDepositClaimable;exports.isDepositPending=t.isDepositPending;exports.isDepositTerminal=t.isDepositTerminal;exports.setReferral=t.setReferral;exports.getNetworkFeeSignature=r.getNetworkFeeSignature;exports.storeNetworkFeeSignature=a.storeNetworkFeeSignature;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/ReferralsClient-CShlPUSW.cjs"),s=require("./chunks/getUserStakeAndBakeSignature-MAvUVkKD.cjs"),i=require("./chunks/get-exchange-ratio-BJcnKt9w.cjs"),t=require("./chunks/depositStatus-JoMTz_wm.cjs"),r=require("./chunks/getNetworkFeeSignature-D_Da-ro1.cjs"),a=require("./chunks/storeNetworkFeeSignature-BHlqcnfa.cjs");exports.ENotarizationStatus=e.ENotarizationStatus;exports.ESessionState=e.ESessionState;exports.PayoutTxStatus=e.PayoutTxStatus;exports.ReferralsClient=e.ReferralsClient;exports.fetchBTCbDeposits=e.fetchBTCbDeposits;exports.fetchDirectDeposits=e.fetchDirectDeposits;exports.fetchUnstakesByAddress=e.fetchUnstakesByAddress;exports.getDepositBtcAddress=e.getDepositBtcAddress;exports.getDepositBtcAddresses=e.getDepositBtcAddresses;exports.getDepositsByAddress=e.getDepositsByAddress;exports.getLuxSeason1Points=e.getLuxSeason1Points;exports.getLuxSeason2Points=e.getLuxSeason2Points;exports.getPointsByAddress=e.getPointsByAddress;exports.getUnstakesByAddress=e.getUnstakesByAddress;exports.storeStakeAndBakeSignature=e.storeStakeAndBakeSignature;exports.SANCTIONED_ADDRESS=s.SANCTIONED_ADDRESS;exports.generateDepositBtcAddress=s.generateDepositBtcAddress;exports.getUserStakeAndBakeSignature=s.getUserStakeAndBakeSignature;exports.getExchangeRatio=i.getExchangeRatio;exports.MIN_CLAIM_AMOUNT_BTC=t.MIN_CLAIM_AMOUNT_BTC;exports.REQUIRED_CONFIRMATIONS=t.REQUIRED_CONFIRMATIONS;exports.calcConfirmations=t.calcConfirmations;exports.depositRequiresAction=t.depositRequiresAction;exports.getConfirmationProgress=t.getConfirmationProgress;exports.getDepositStatus=t.getDepositStatus;exports.getDepositStatusDisplay=t.getDepositStatusDisplay;exports.getLBTCExchangeRate=t.getLBTCExchangeRate;exports.isDepositClaimable=t.isDepositClaimable;exports.isDepositPending=t.isDepositPending;exports.isDepositTerminal=t.isDepositTerminal;exports.setReferral=t.setReferral;exports.getNetworkFeeSignature=r.getNetworkFeeSignature;exports.storeNetworkFeeSignature=a.storeNetworkFeeSignature;
2
2
  //# sourceMappingURL=api.cjs.map
package/dist/api.js CHANGED
@@ -1,9 +1,9 @@
1
- import { ENotarizationStatus as s, ESessionState as o, PayoutTxStatus as r, ReferralsClient as i, fetchBTCbDeposits as a, fetchDirectDeposits as n, fetchUnstakesByAddress as g, getDepositBtcAddress as p, getDepositBtcAddresses as d, getDepositsByAddress as S, getLuxSeason1Points as D, getLuxSeason2Points as A, getPointsByAddress as f, getUnstakesByAddress as c, storeStakeAndBakeSignature as u } from "./chunks/ReferralsClient-BNwB6wO4.js";
2
- import { SANCTIONED_ADDRESS as x, generateDepositBtcAddress as m, getUserStakeAndBakeSignature as C } from "./chunks/getUserStakeAndBakeSignature-CQsvL79O.js";
3
- import { getExchangeRatio as R } from "./chunks/get-exchange-ratio-BvPUfcIQ.js";
4
- import { MIN_CLAIM_AMOUNT_BTC as l, REQUIRED_CONFIRMATIONS as E, calcConfirmations as T, depositRequiresAction as y, getConfirmationProgress as I, getDepositStatus as P, getDepositStatusDisplay as h, getLBTCExchangeRate as U, isDepositClaimable as _, isDepositPending as L, isDepositTerminal as M, setReferral as O } from "./chunks/depositStatus-hmXphYhu.js";
5
- import { getNetworkFeeSignature as b } from "./chunks/getNetworkFeeSignature-FuDJWrMC.js";
6
- import { storeNetworkFeeSignature as q } from "./chunks/storeNetworkFeeSignature-sCt4_nHr.js";
1
+ import { ENotarizationStatus as s, ESessionState as o, PayoutTxStatus as r, ReferralsClient as i, fetchBTCbDeposits as a, fetchDirectDeposits as n, fetchUnstakesByAddress as g, getDepositBtcAddress as p, getDepositBtcAddresses as d, getDepositsByAddress as S, getLuxSeason1Points as D, getLuxSeason2Points as A, getPointsByAddress as f, getUnstakesByAddress as c, storeStakeAndBakeSignature as u } from "./chunks/ReferralsClient-CM2YjtPf.js";
2
+ import { SANCTIONED_ADDRESS as x, generateDepositBtcAddress as m, getUserStakeAndBakeSignature as C } from "./chunks/getUserStakeAndBakeSignature-Dvrkir30.js";
3
+ import { getExchangeRatio as R } from "./chunks/get-exchange-ratio-O4BrIkv0.js";
4
+ import { MIN_CLAIM_AMOUNT_BTC as l, REQUIRED_CONFIRMATIONS as E, calcConfirmations as T, depositRequiresAction as y, getConfirmationProgress as I, getDepositStatus as P, getDepositStatusDisplay as h, getLBTCExchangeRate as U, isDepositClaimable as _, isDepositPending as L, isDepositTerminal as M, setReferral as O } from "./chunks/depositStatus-xVBInKTX.js";
5
+ import { getNetworkFeeSignature as b } from "./chunks/getNetworkFeeSignature-DVY1Dlh-.js";
6
+ import { storeNetworkFeeSignature as q } from "./chunks/storeNetworkFeeSignature-9YVYoLyK.js";
7
7
  export {
8
8
  s as ENotarizationStatus,
9
9
  o as ESessionState,
package/dist/bridge.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("./chunks/bridge-CQmXrRKS.cjs");exports.OFT_GAS_LIMIT=I.OFT_GAS_LIMIT;exports.OFT_HI_GAS_LIMIT=I.OFT_HI_GAS_LIMIT;exports.OFT_HI_GAS_LIMIT_CHAINS=I.OFT_HI_GAS_LIMIT_CHAINS;exports.bridge=I.bridge;exports.bridgeCCIP=I.bridgeCCIP;exports.bridgeOFT=I.bridgeOFT;exports.getBridgeInfo=I.getBridgeInfo;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("./chunks/bridge-CnEVkvXU.cjs");exports.OFT_GAS_LIMIT=I.OFT_GAS_LIMIT;exports.OFT_HI_GAS_LIMIT=I.OFT_HI_GAS_LIMIT;exports.OFT_HI_GAS_LIMIT_CHAINS=I.OFT_HI_GAS_LIMIT_CHAINS;exports.bridge=I.bridge;exports.bridgeCCIP=I.bridgeCCIP;exports.bridgeOFT=I.bridgeOFT;exports.getBridgeInfo=I.getBridgeInfo;
2
2
  //# sourceMappingURL=bridge.cjs.map
package/dist/bridge.js CHANGED
@@ -1,4 +1,4 @@
1
- import { OFT_GAS_LIMIT as T, OFT_HI_GAS_LIMIT as e, OFT_HI_GAS_LIMIT_CHAINS as r, bridge as g, bridgeCCIP as d, bridgeOFT as i, getBridgeInfo as A } from "./chunks/bridge-DnDIoRdh.js";
1
+ import { OFT_GAS_LIMIT as T, OFT_HI_GAS_LIMIT as e, OFT_HI_GAS_LIMIT_CHAINS as r, bridge as g, bridgeCCIP as d, bridgeOFT as i, getBridgeInfo as A } from "./chunks/bridge-E90jjF8n.js";
2
2
  export {
3
3
  T as OFT_GAS_LIMIT,
4
4
  e as OFT_HI_GAS_LIMIT,
package/dist/btc.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/BtcActions-DZs5eXTb.cjs"),c=require("./chunks/statusConstants-Cz77HXnT.cjs");exports.BtcActions=t.BtcActions;exports.BtcDeposit=t.BtcDeposit;exports.BtcDepositAndDeploy=t.BtcDepositAndDeploy;exports.BtcStake=t.BtcStake;exports.BtcStakeAndDeploy=t.BtcStakeAndDeploy;exports.btcActions=t.btcActions;exports.btcModule=t.btcModule;exports.BtcActionStatus=c.BtcActionStatus;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/BtcActions-CaoeJtse.cjs"),c=require("./chunks/statusConstants-D8Rb7g7_.cjs");exports.BtcActions=t.BtcActions;exports.BtcDeposit=t.BtcDeposit;exports.BtcDepositAndDeploy=t.BtcDepositAndDeploy;exports.BtcStake=t.BtcStake;exports.BtcStakeAndDeploy=t.BtcStakeAndDeploy;exports.btcActions=t.btcActions;exports.btcModule=t.btcModule;exports.BtcActionStatus=c.BtcActionStatus;
2
2
  //# sourceMappingURL=btc.cjs.map
package/dist/btc.js CHANGED
@@ -1,5 +1,5 @@
1
- import { BtcActions as c, BtcDeposit as e, BtcDepositAndDeploy as p, BtcStake as B, BtcStakeAndDeploy as i, btcActions as n, btcModule as s } from "./chunks/BtcActions-BDTnGE1D.js";
2
- import { BtcActionStatus as r } from "./chunks/statusConstants-DZlImWu7.js";
1
+ import { BtcActions as c, BtcDeposit as e, BtcDepositAndDeploy as p, BtcStake as B, BtcStakeAndDeploy as i, btcActions as n, btcModule as s } from "./chunks/BtcActions-D7N6pivv.js";
2
+ import { BtcActionStatus as r } from "./chunks/statusConstants-CC4bJf0C.js";
3
3
  export {
4
4
  r as BtcActionStatus,
5
5
  c as BtcActions,
@@ -1,2 +1,2 @@
1
- "use strict";var z=Object.defineProperty;var H=(s,r,i)=>r in s?z(s,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[r]=i;var p=(s,r,i)=>H(s,typeof r!="symbol"?r+"":r,i);const Y=require("axios"),t=require("./statusConstants-Cz77HXnT.cjs"),A=require("./token-addresses-C7H9E4qz.cjs"),u=require("./index-BKzxeh1Y.cjs"),I=require("./tokens-C5rzCTTM.cjs"),f=require("./satoshi-CZEsHl5X.cjs"),c=require("./defi-registry-CyMKVT3z.cjs"),R=require("./getUserStakeAndBakeSignature-Cwwx89pR.cjs"),q=require("./config-BfX8lrdO.cjs"),$=require("./storeNetworkFeeSignature-BaG3AU8U.cjs"),U=require("viem"),G="ERR_NETWORK",j="This may be due to your Adblocker. Please disable any Adblocker and refresh the page to restore full functionality.";function K(s){const{code:r,message:i}=s;throw r===G?new Error(j):new Error(i)}const Z={mempoolApiUrl:"https://mempool.space/signet"},W={mempoolApiUrl:"https://mempool.space"},X=s=>s==="mainnet"?W:Z;async function J(s){const{mempoolApiUrl:r}=X(s),i=Math.floor(Date.now()/1e3),e=`${r}/api/v1/mining/blocks/timestamp/${i}`;try{const{data:n}=await Y.get(e);return n.height}catch(n){K(n)}}class Q{async getCurrentBlockHeight(r){return J(r)}}function tt(){return{id:"btc",chain:"btc",register(){return new Q}}}async function N(s){const{fetchDeposit:r,network:i,btcService:e,requiredConfirmations:n=6,onProgress:a,onComplete:o}=s,h=await r();if(!h)return;const d=h.blockHeight;if(typeof d!="number")return;const C=await e.getCurrentBlockHeight(i),S=Math.max(0,C-d),_=S>=n,y=h.isClaimed??!1,B={confirmations:S,requiredConfirmations:n,hasEnoughConfirmations:_,isClaimed:y,steps:{created:t.StepStatus.COMPLETE,verifying:_?t.StepStatus.COMPLETE:t.StepStatus.PENDING,issuing:y?t.StepStatus.COMPLETE:t.StepStatus.PENDING}};return a==null||a(B),y&&(o==null||o()),B}function m(s){if(s===R.SANCTIONED_ADDRESS)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Destination address is under sanctions")}class T extends t.BaseAction{constructor(i,e,n){super(n);p(this,"_amount");p(this,"_recipient");p(this,"_depositAddress");p(this,"_referralCode");p(this,"_chainId");this.ctx=i,this.params=e}get amount(){return this._amount}get recipient(){return this._recipient}get depositAddress(){return this._depositAddress}get referralCode(){return this._referralCode}get bitcoinNetwork(){return this.params.sourceChain===t.Chain.BITCOIN_MAINNET?"mainnet":"testnet"}get prepareSchema(){return t.objectType({amount:t.btcStakeAmountSchema,recipient:this.getAddressSchema(),referralCode:t.referralCodeSchema})}validatePrepareParams(i){return t.validatePrepareParams(this.prepareSchema,i,{destChain:this.params.destChain})}ensureRecipient(){if(!this._recipient)throw t.LombardError.missingParameter("recipient");return this._recipient}ensureAmount(){if(!this._amount)throw t.LombardError.missingParameter("amount");return this._amount}ensureDepositAddress(){if(!this._depositAddress)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Deposit address not generated. Call generateDepositAddress() first.");return this._depositAddress}getAuthRequiredMessage(){return"Authorization required. Complete the authorization step first."}ensureAuthorized(){if(!this.isAuthorized())throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,this.getAuthRequiredMessage())}async resumeFromExistingDeposit(i){try{const e=await this.ctx.api.getDepositAddress({address:i,chainId:this.getChainId(),token:this.getExpectedToken(),partnerId:this.ctx.partner.getPartnerId()});return e?(this._depositAddress=e,!0):!1}catch{return!1}}async generateDepositAddressImpl(i){const e=this.getStatusConfig();return this.assertStatus(e.ready,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const n=this.getDepositAddressParams(i),a=await this.ctx.api.generateDepositAddress(n);m(a),this._depositAddress=a;const o=this.getInitialSteps(),h=Object.fromEntries(Object.entries(o).map(([d],C)=>[d,C===0?t.StepStatus.COMPLETE:t.StepStatus.IDLE]));return this.emitProgress({status:e.addressReady,steps:h,metadata:{depositAddress:a}}),a},e.addressReady)}async executeImpl(){const i=this.getStatusConfig();return this.act(async()=>{this.assertStatus(i.addressReady,"execute"),this._depositAddress||await this.generateDepositAddressImpl();const e=this.ensureDepositAddress(),n=await this.trySendBitcoin(e);return n?{depositAddress:e,txHash:n}:{depositAddress:e}})}emitInitialProgress(){this.emitProgress({status:this.status,steps:this.getInitialSteps()})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await N({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:a=>{this.emitProgress({status:this.status,steps:a.steps,confirmations:a.confirmations,requiredConfirmations:a.requiredConfirmations,metadata:{isClaimed:a.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}async trySendBitcoin(i){const e=this._amount;if(e)try{const n=await this.ctx.getProvider("bitcoin");if(!n)return;const a=n;if(a.sendBitcoin){const o=f.toSatoshi(e).toNumber();return a.sendBitcoin(i,o)}}catch{}}}function l(s,r=A.Token.LBTC){switch(s){case c.AssetId.LBTC:return A.Token.LBTC;case c.AssetId.BTCb:return A.Token.BTCb;default:return r}}async function et(s,r){try{await s.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${r.toString(16)}`}]})}catch(i){const e=i;if(e.code===4902)try{await A.addChain({provider:s,chainId:r}),await s.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${r.toString(16)}`}]});return}catch(n){const a=n;throw a.code===4001?new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"User rejected adding chain to wallet."):new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Failed to add chain ${r} to wallet: ${a.message||"Unknown error"}`)}throw e.code===4001?new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"User rejected chain switch request."):new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Failed to switch to chain ${r}: ${e.message||"Unknown error"}`)}}async function st(s){const r=await s.request({method:"eth_chainId"});return parseInt(r,16)}async function D(s,r){await st(s)!==r&&await et(s,r)}const it=[t.Chain.ETHEREUM,t.Chain.SEPOLIA],rt={async getMintingFee(s,r){return s.capabilities.require("evm").getMintingFee(r,A.Token.BTCb)},async restoreFeeSignature(s,r,i){const e=await I.getTokenContractInfo(A.Token.BTCb,r,s.env),n=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:e.address});return!n.hasSignature||n.expirationDate&&new Date(Number(n.expirationDate)*1e3)<new Date?null:{hasSignature:!0,signature:n.signature,typedData:n.typedData}},async authorizeFee(s,{chainId:r,recipient:i,fee:e}){const n=s.capabilities.require("evm"),a=await s.getProvider("evm");if(!a)throw t.LombardError.providerMissing(String(r),"evm");await D(a,r);const o=f.toSatoshi(e).toString(),h=await I.getTokenContractInfo(A.Token.BTCb,r,s.env),d=await n.signNetworkFee({fee:o,account:i,chainId:r,provider:a,token:A.Token.BTCb});return await s.api.storeFeeSignature({address:i,signature:d.signature,typedData:d.typedData,tokenAddress:h.address}),{signature:d.signature,typedData:d.typedData}}},at={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.BTCb).filter(s=>t.isEvmChain(s)),supportedAssetsOut:[c.AssetId.BTCb],addressSchema:t.evmAddressSchema,getFeeAuthConfig(s){return it.includes(s)?rt:null},async signDestination(s,r,i){const e=s.capabilities.require("evm"),n=await s.getProvider("evm");if(!n)throw t.LombardError.providerMissing(String(i),"evm");return await D(n,i),{signature:(await e.signLbtcDestination({address:r,chainId:i,provider:n})).signature}}},w=s=>`${s}${t.CAIP2_SEPARATOR}`;function nt(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.EIP155))}function b(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.SOLANA))}function ot(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.SUI))}function ut(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.STARKNET))}function dt(s){const r={[t.Chain.SOLANA_MAINNET]:"mainnet-beta",[t.Chain.SOLANA_DEVNET]:"devnet",[t.Chain.SOLANA_TESTNET]:"testnet","solana:mainnet-beta":"mainnet-beta","solana:devnet":"devnet","solana:testnet":"testnet"},i=r[s];if(!i)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unknown Solana chain: ${s}. Expected one of: ${Object.keys(r).join(", ")}`);return i}const ct={chainType:"solana",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet]}],destChains:t.getAllAssetChains(c.AssetId.BTCb).filter(s=>b(s)),supportedAssetsOut:[c.AssetId.BTCb],addressSchema:t.solanaAddressSchema,getFeeAuthConfig:()=>null,async signDestination(s,r,i){const e=s.capabilities.require("solana"),n=dt(i),{signature:a}=await e.signLbtcDestination({network:n});return{signature:a}}},ht={evm:at,solana:ct};function pt(s){return ht[s]}function At(s,r){return s.destChains.includes(r)}function St(s,r){return s.supportedAssetsOut.includes(r)}function gt(s,r,i){return s.routes.some(e=>e.envs.includes(i)&&(!r||e.sourceChains.includes(r)))}class k extends T{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"config");p(this,"chainId");p(this,"authState",{authorized:!1});p(this,"feeAuthConfig",null);const n=t.getChainType(e.destChain),a=pt(n);if(!a)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported destination chain type: ${n} (${e.destChain})`);if(!St(a,e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for BTC deposits. BTC Deposit produces BTC.b. For LBTC, use BtcStake instead.`);if(!At(a,e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for ${n} BTC deposits`);if(!gt(a,e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});this.config=a,this.chainId=t.parseChainIdentifier(e.destChain)}getAddressSchema(){return this.config.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}get mintingFee(){return this.authState.mintingFee}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),eip712Data:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}async generateDepositAddress(i){if(!this.authState.signature){const e=await this.config.signDestination(this.ctx,this.ensureRecipient(),this.chainId);this.authState.signature=e.signature,this.authState.typedData=e.typedData}return this.generateDepositAddressImpl(i)}getExpectedToken(){return l(this.params.assetOut,A.Token.BTCb)}getAuthRequiredMessage(){return this.feeAuthConfig?"Fee authorization required. Call authorizeFee() first.":"Address confirmation required. Call confirmAddress() first."}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.feeAuthConfig=this.config.getFeeAuthConfig(this.params.destChain),await this.resumeFromExistingDeposit(e.recipient)){if(this.feeAuthConfig){const a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(!(a!=null&&a.hasSignature)){this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION),this.emitInitialProgress();return}a.signature&&(this.authState.signature=a.signature,this.authState.typedData=a.typedData),this.authState.authorized=!0}this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}if(this.feeAuthConfig){const a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(a!=null&&a.hasSignature){a.signature&&(this.authState.signature=a.signature,this.authState.typedData=a.typedData),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION)}else this.updateStatus(t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION);this.emitInitialProgress()})}async authorizeFee(){if(this.assertStatus([t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeFee"),this.status===t.BtcActionStatus.READY)return;if(!this.feeAuthConfig)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Fee authorization is not required for this destination chain. Use confirmAddress() instead.");const i=this.ensureRecipient();if(!this.authState.mintingFee)throw new t.LombardError(t.ValidationErrorCode.INVALID_STATE,"Minting fee not available. Call prepare() first.");return this.act(async()=>{const e=await this.feeAuthConfig.authorizeFee(this.ctx,{chainId:this.chainId,recipient:i,fee:this.authState.mintingFee});this.authState.signature=e.signature,this.authState.typedData=e.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async confirmAddress(){if(this.assertStatus([t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION,t.BtcActionStatus.READY],"confirmAddress"),this.status===t.BtcActionStatus.READY)return;if(this.feeAuthConfig)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"This destination chain requires fee authorization. Use authorizeFee() instead.");const i=this.ensureRecipient();return this.act(async()=>{const e=await this.config.signDestination(this.ctx,i,this.chainId);this.authState.signature=e.signature,this.authState.typedData=e.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async execute(){return this.executeImpl()}async monitorDeposit(){return super.monitorDeposit()}}const Ct=q.EARN_STAKE_AND_BAKE_CHAINS.map(s=>t.evmChainIdToChain(s)),Et={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:Ct,supportedAssetsOut:[c.AssetId.LBTC],supportedProtocols:Nt(c.AssetId.LBTC),addressSchema:t.evmAddressSchema,async getStakeAndBakeFee(s,r,i){return s.capabilities.require("evm").getStakeAndBakeFee(r,i)},async authorizeStakeAndBake(s,{chainId:r,recipient:i,amount:e,vaultKey:n,token:a}){const o=s.capabilities.require("evm"),h=await s.getProvider("evm");if(!h)throw t.LombardError.providerMissing(String(r),"evm");await D(h,r);const d=await o.signStakeAndBake({value:e,account:i,chainId:r,provider:h,vaultKey:n,token:a});return await s.api.storeStakeAndBakeSignature({signature:d.signature,typedData:d.typedData}),{signature:d.signature,typedData:d.typedData}},async restoreStakeAndBakeSignature(s,r,i){try{const e=await R.getUserStakeAndBakeSignature({userDestinationAddress:i,chainId:r,env:s.env});return!(e.signature||e.expirationDate)||e.expirationDate&&Number(e.expirationDate)*1e3<Date.now()?null:{hasSignature:!0,signature:e.signature,depositAmount:e.depositAmount,expirationDate:e.expirationDate}}catch{return null}}},g=Et;function Dt(s){return g.destChains.includes(s)}function lt(s){return g.supportedAssetsOut.includes(s)}function ft(s,r){return s?g.routes.some(i=>i.sourceChains.includes(s)&&i.envs.includes(r)):!0}function O(s){return s in c.DEFI_REGISTRY}function It(s){if(!O(s)){const r=Object.keys(c.DEFI_REGISTRY).join(", ");throw new Error(`Unsupported protocol: ${s}. Supported protocols: ${r}`)}return s}function mt(s){return Object.entries(c.DEFI_REGISTRY).filter(([r,i])=>s in i).map(([r])=>r)}const v={mainnet:[t.Chain.AVALANCHE],testnet:[t.Chain.AVALANCHE_FUJI]},Tt={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:[...v.mainnet,...v.testnet],supportedAssetsOut:[c.AssetId.BTCb],supportedProtocols:mt(c.AssetId.BTCb),addressSchema:t.evmAddressSchema,async getDepositAndDeployFee(s,r,i){return s.capabilities.require("evm").getStakeAndBakeFee(r,i)},async authorizeDepositAndDeploy(s,{chainId:r,recipient:i,amount:e,vaultKey:n,token:a}){const o=s.capabilities.require("evm"),h=await s.getProvider("evm");if(!h)throw t.LombardError.providerMissing(String(r),"evm");await D(h,r);const d=await o.signStakeAndBake({value:e,account:i,chainId:r,provider:h,vaultKey:n,token:a});return await s.api.storeStakeAndBakeSignature({signature:d.signature,typedData:d.typedData}),{signature:d.signature,typedData:d.typedData,approvalTxHash:d.approvalTxHash}}},E=Tt;function wt(s){return E.destChains.includes(s)}function yt(s){return E.supportedAssetsOut.includes(s)}function P(s){return s in c.DEFI_REGISTRY}function L(s){if(!P(s)){const r=Object.keys(c.DEFI_REGISTRY).join(", ");throw new Error(`Unsupported protocol: ${s}. Supported protocols: ${r}`)}return s}function Nt(s){return Object.entries(c.DEFI_REGISTRY).filter(([r,i])=>s in i).map(([r])=>r)}function _t(s,r){return E.routes.some(i=>i.sourceChains.includes(s)&&i.envs.includes(r))}class F extends T{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"chainId");p(this,"authState",{authorized:!1});if(!yt(e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for deposit and deploy. DepositAndDeploy produces BTC.b which is then deployed to a vault like Silo.`);if(!wt(e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for deposit and deploy. Supported chains: Avalanche, Avalanche Fuji`);if(!P(e.protocol))throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,`Protocol ${e.protocol} is not supported for deposit and deploy. DepositAndDeploy with BTC.b only supports Silo protocol.`);const n=e.sourceChain??t.Chain.BITCOIN_MAINNET;if(!_t(n,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:n,destChain:e.destChain,env:i.env});const a=t.parseChainIdentifier(e.destChain);if(typeof a!="number"||!A.isValidChain(a))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported EVM chain: ${e.destChain}`);this.chainId=a}getAddressSchema(){return E.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,wrapping:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),signatureData:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return l(this.params.assetOut,A.Token.BTCb)}getAuthRequiredMessage(){return"Deposit authorization required. Call authorizeDeposit() first."}get fee(){return this.authState.fee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.authState.fee=await E.getDepositAndDeployFee(this.ctx,this.chainId,L(this.params.protocol)),this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress()},t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION)}async authorizeDeposit(){if(this.assertStatus([t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeDeposit"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.ensureAmount();return this.act(async()=>{const n=f.toSatoshi(e),a=l(this.params.assetOut,A.Token.BTCb),o=await E.authorizeDepositAndDeploy(this.ctx,{chainId:this.chainId,recipient:i,amount:n.toString(),vaultKey:L(this.params.protocol),token:a});this.authState.signature=o.signature,this.authState.typedData=o.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){return this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const e=this.getDepositAddressParams(i),n=await this.ctx.api.generateDepositAddress(e);return m(n),this._depositAddress=n,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,wrapping:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE},metadata:{depositAddress:n}}),n},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.act(async()=>{this.assertStatus(t.BtcActionStatus.ADDRESS_READY,"execute"),this._depositAddress||await this.generateDepositAddress();const i=this.ensureDepositAddress(),e=await this.trySendBitcoin(i);return e?{depositAddress:i,txHash:e}:{depositAddress:i}})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await N({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:a=>{this.emitProgress({status:this.status,steps:{created:t.StepStatus.COMPLETE,verifying:a.hasEnoughConfirmations?t.StepStatus.COMPLETE:t.StepStatus.PENDING,wrapping:a.isClaimed?t.StepStatus.COMPLETE:t.StepStatus.PENDING,depositing:t.StepStatus.PENDING},confirmations:a.confirmations,requiredConfirmations:a.requiredConfirmations,metadata:{isClaimed:a.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}}const Bt=[t.Chain.ETHEREUM,t.Chain.SEPOLIA],vt={async getMintingFee(s,r){return s.capabilities.require("evm").getMintingFee(r)},async restoreFeeSignature(s,r,i){const e=await I.getTokenContractInfo(A.Token.LBTC,r,s.env),n=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:e.address});return!n.hasSignature||n.expirationDate&&new Date(Number(n.expirationDate)*1e3)<new Date?null:{hasSignature:!0,signature:n.signature,typedData:n.typedData}},async authorizeFee(s,{chainId:r,recipient:i,fee:e}){const n=s.capabilities.require("evm"),a=await s.getProvider("evm");if(!a)throw t.LombardError.providerMissing(String(r),"evm");await D(a,r);const o=f.toSatoshi(e).toString(),h=await I.getTokenContractInfo(A.Token.LBTC,r,s.env),d=await n.signNetworkFee({fee:o,account:i,chainId:r,provider:a,token:A.Token.LBTC});try{await s.api.storeFeeSignature({address:i,signature:d.signature,typedData:d.typedData,tokenAddress:h.address})}catch(C){if(!(C instanceof $.FeeSignatureAlreadyExistsError))throw C;const S=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:h.address});if(S!=null&&S.hasSignature)return{signature:S.signature??d.signature,typedData:S.typedData??d.typedData};throw new Error("A fee authorization signature already exists for this account but cannot be retrieved. Refresh the page and try again, or contact support if this persists.")}return{signature:d.signature,typedData:d.typedData}}},Lt={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>nt(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.evmAddressSchema,getFeeAuthConfig(s){return Bt.includes(s)?vt:null},async getSignature(s,r,i){const e=s.capabilities.require("evm"),n=await s.getProvider("evm");if(!n)throw t.LombardError.providerMissing(String(i),"evm");return await D(n,i),e.signLbtcDestination({chainId:i,address:r,provider:n})}};function Rt(s){const r={[t.Chain.SOLANA_MAINNET]:"mainnet-beta",[t.Chain.SOLANA_DEVNET]:"devnet",[t.Chain.SOLANA_TESTNET]:"testnet","solana:mainnet-beta":"mainnet-beta","solana:devnet":"devnet","solana:testnet":"testnet"},i=r[s];if(!i)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unknown Solana chain: ${s}. Expected one of: ${Object.keys(r).join(", ")}`);return i}const bt={chainType:"solana",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>b(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.solanaAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("solana"),n=Rt(i),{signature:a}=await e.signLbtcDestination({network:n});return{signature:a}}},kt={chainType:"starknet",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>ut(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.starknetAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("starknet"),{signature:n,pubKey:a}=await e.signLbtcDestination({chainId:i}),o=U.pad(r,{size:32});return{signature:n,pubKey:a,paddedAddress:o}}},Ot={chainType:"sui",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>ot(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.suiAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("sui"),{signature:n}=await e.signLbtcDestination({chainId:i});return{signature:n}}},Pt={evm:Lt,solana:bt,sui:Ot,starknet:kt};function Ft(s){return Pt[s]}function xt(s,r,i){return r?s.routes.some(e=>e.sourceChains.includes(r)&&e.envs.includes(i)):!0}function Mt(s,r){return s.destChains.includes(r)}function Vt(s,r){return s.supportedAssetsOut.includes(r)}class x extends T{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"config");p(this,"chainId");p(this,"authState",{authorized:!1});p(this,"feeAuthConfig",null);const n=t.getChainType(e.destChain),a=Ft(n);if(!a)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported destination chain type: ${n} (${e.destChain})`);if(!Vt(a,e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for BTC staking. BTC Stake produces LBTC. For BTC.b, use BtcDeposit instead.`);if(!Mt(a,e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for ${n}`);if(!xt(a,e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});this.config=a,this.chainId=t.parseChainIdentifier(e.destChain)}getAddressSchema(){return this.config.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){var a;const e=this.ensureRecipient(),n=this.getActiveSignature();if(!n)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Missing signature. Complete authorization first.");return{address:n.paddedAddress??e,chainId:this.chainId,signature:n.signature,token:this.getExpectedToken(),eip712Data:(a=this.authState.networkFee)==null?void 0:a.typedData,pubKey:n.pubKey,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return l(this.params.assetOut,A.Token.LBTC)}getAuthRequiredMessage(){return"Authorization required. Call authorize() first."}get mintingFee(){return this.authState.mintingFee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.feeAuthConfig=this.config.getFeeAuthConfig(this.params.destChain),await this.resumeFromExistingDeposit(e.recipient)){if(this.feeAuthConfig){const a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(!(a!=null&&a.hasSignature)){this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION),this.emitInitialProgress();return}a.signature&&(this.authState.networkFee={signature:a.signature,typedData:a.typedData}),this.authState.authorized=!0}this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}if(this.feeAuthConfig){const a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(a!=null&&a.hasSignature){a.signature&&(this.authState.networkFee={signature:a.signature,typedData:a.typedData}),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION)}else this.updateStatus(t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION);this.emitInitialProgress()})}async authorize(){if(this.assertStatus([t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION,t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION,t.BtcActionStatus.READY],"authorize"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.feeAuthConfig!==null;return this.act(async()=>{if(e){const n=this.ensureMintingFee(),a=await this.feeAuthConfig.authorizeFee(this.ctx,{chainId:this.chainId,recipient:i,fee:n});this.authState.networkFee={signature:a.signature,typedData:a.typedData}}else this.authState.destinationSignature=await this.config.getSignature(this.ctx,i,this.chainId);this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){if(this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress)return this._depositAddress;if(!this.getActiveSignature()){const e=await this.config.getSignature(this.ctx,this.ensureRecipient(),this.chainId);this.authState.destinationSignature=e}return this.act(async()=>{const e=this.getDepositAddressParams(i),n=await this.ctx.api.generateDepositAddress(e);return m(n),this._depositAddress=n,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE},metadata:{depositAddress:n}}),n},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.executeImpl()}async monitorDeposit(){return super.monitorDeposit()}ensureMintingFee(){if(!this.authState.mintingFee)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Minting fee not fetched. Call prepare() first.");return this.authState.mintingFee}getActiveSignature(){var i;return(i=this.authState.networkFee)!=null&&i.signature?{signature:this.authState.networkFee.signature}:this.authState.destinationSignature}}class M extends T{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"chainId");p(this,"authState",{authorized:!1});if(!lt(e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for stake and deploy. StakeAndDeploy produces LBTC which is then deployed to a vault.`);if(!Dt(e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for stake and deploy`);if(!O(e.protocol))throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,`Protocol ${e.protocol} is not supported for stake and deploy`);if(!ft(e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});const n=t.parseChainIdentifier(e.destChain);if(typeof n!="number"||!A.isValidChain(n))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported EVM chain: ${e.destChain}`);this.chainId=n}getAddressSchema(){return g.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),signatureData:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return l(this.params.assetOut,A.Token.LBTC)}getAuthRequiredMessage(){return"Deposit authorization required. Call authorizeDeposit() first."}get fee(){return this.authState.fee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.authState.fee=await g.getStakeAndBakeFee(this.ctx,this.chainId,this.params.protocol),await this.resumeFromExistingDeposit(e.recipient)){const o=await g.restoreStakeAndBakeSignature(this.ctx,this.chainId,e.recipient);if(o!=null&&o.hasSignature){o.signature&&(this.authState.signature=o.signature),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress();return}const a=await g.restoreStakeAndBakeSignature(this.ctx,this.chainId,e.recipient);if(a!=null&&a.hasSignature){a.signature&&(this.authState.signature=a.signature),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress()})}async authorizeDeposit(){if(this.assertStatus([t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeDeposit"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.ensureAmount();return this.act(async()=>{const n=f.toSatoshi(e),a=this.params.assetIn??c.AssetId.BTC,o=await g.authorizeStakeAndBake(this.ctx,{chainId:this.chainId,recipient:i,amount:n.toString(),vaultKey:It(this.params.protocol),token:a});this.authState.signature=o.signature,this.authState.typedData=o.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){return this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const e=this.getDepositAddressParams(i),n=await this.ctx.api.generateDepositAddress(e);return m(n),this._depositAddress=n,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE},metadata:{depositAddress:n}}),n},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.act(async()=>{this.assertStatus(t.BtcActionStatus.ADDRESS_READY,"execute"),this._depositAddress||await this.generateDepositAddress();const i=this.ensureDepositAddress(),e=await this.trySendBitcoin(i);return e?{depositAddress:i,txHash:e}:{depositAddress:i}})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await N({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:a=>{this.emitProgress({status:this.status,steps:{created:t.StepStatus.COMPLETE,verifying:a.hasEnoughConfirmations?t.StepStatus.COMPLETE:t.StepStatus.PENDING,issuing:a.isClaimed?t.StepStatus.COMPLETE:t.StepStatus.PENDING,depositing:t.StepStatus.PENDING},confirmations:a.confirmations,requiredConfirmations:a.requiredConfirmations,metadata:{isClaimed:a.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}}class V{constructor(r){p(this,"ctx");this.ctx=t.createBtcCoreContext(r)}stake(r){return new x(this.ctx,r)}stakeAndDeploy(r){return new M(this.ctx,r)}deposit(r){return new k(this.ctx,r)}depositAndDeploy(r){return new F(this.ctx,r)}}function zt(s){return new V(s)}exports.BtcActions=V;exports.BtcDeposit=k;exports.BtcDepositAndDeploy=F;exports.BtcStake=x;exports.BtcStakeAndDeploy=M;exports.btcActions=zt;exports.btcModule=tt;
2
- //# sourceMappingURL=BtcActions-DZs5eXTb.cjs.map
1
+ "use strict";var z=Object.defineProperty;var H=(s,r,i)=>r in s?z(s,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[r]=i;var p=(s,r,i)=>H(s,typeof r!="symbol"?r+"":r,i);const Y=require("axios"),t=require("./statusConstants-D8Rb7g7_.cjs"),A=require("./token-addresses-C7H9E4qz.cjs"),u=require("./index-BKzxeh1Y.cjs"),I=require("./tokens-Di3O7wcg.cjs"),f=require("./satoshi-CZEsHl5X.cjs"),c=require("./defi-registry-CyMKVT3z.cjs"),R=require("./getUserStakeAndBakeSignature-MAvUVkKD.cjs"),q=require("./config-BfX8lrdO.cjs"),$=require("./storeNetworkFeeSignature-BHlqcnfa.cjs"),U=require("viem"),G="ERR_NETWORK",j="This may be due to your Adblocker. Please disable any Adblocker and refresh the page to restore full functionality.";function K(s){const{code:r,message:i}=s;throw r===G?new Error(j):new Error(i)}const Z={mempoolApiUrl:"https://mempool.space/signet"},W={mempoolApiUrl:"https://mempool.space"},X=s=>s==="mainnet"?W:Z;async function J(s){const{mempoolApiUrl:r}=X(s),i=Math.floor(Date.now()/1e3),e=`${r}/api/v1/mining/blocks/timestamp/${i}`;try{const{data:n}=await Y.get(e);return n.height}catch(n){K(n)}}class Q{async getCurrentBlockHeight(r){return J(r)}}function tt(){return{id:"btc",chain:"btc",register(){return new Q}}}async function N(s){const{fetchDeposit:r,network:i,btcService:e,requiredConfirmations:n=6,onProgress:a,onComplete:o}=s,h=await r();if(!h)return;const d=h.blockHeight;if(typeof d!="number")return;const C=await e.getCurrentBlockHeight(i),S=Math.max(0,C-d),_=S>=n,y=h.isClaimed??!1,B={confirmations:S,requiredConfirmations:n,hasEnoughConfirmations:_,isClaimed:y,steps:{created:t.StepStatus.COMPLETE,verifying:_?t.StepStatus.COMPLETE:t.StepStatus.PENDING,issuing:y?t.StepStatus.COMPLETE:t.StepStatus.PENDING}};return a==null||a(B),y&&(o==null||o()),B}function m(s){if(s===R.SANCTIONED_ADDRESS)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Destination address is under sanctions")}class T extends t.BaseAction{constructor(i,e,n){super(n);p(this,"_amount");p(this,"_recipient");p(this,"_depositAddress");p(this,"_referralCode");p(this,"_chainId");this.ctx=i,this.params=e}get amount(){return this._amount}get recipient(){return this._recipient}get depositAddress(){return this._depositAddress}get referralCode(){return this._referralCode}get bitcoinNetwork(){return this.params.sourceChain===t.Chain.BITCOIN_MAINNET?"mainnet":"testnet"}get prepareSchema(){return t.objectType({amount:t.btcStakeAmountSchema,recipient:this.getAddressSchema(),referralCode:t.referralCodeSchema})}validatePrepareParams(i){return t.validatePrepareParams(this.prepareSchema,i,{destChain:this.params.destChain})}ensureRecipient(){if(!this._recipient)throw t.LombardError.missingParameter("recipient");return this._recipient}ensureAmount(){if(!this._amount)throw t.LombardError.missingParameter("amount");return this._amount}ensureDepositAddress(){if(!this._depositAddress)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Deposit address not generated. Call generateDepositAddress() first.");return this._depositAddress}getAuthRequiredMessage(){return"Authorization required. Complete the authorization step first."}ensureAuthorized(){if(!this.isAuthorized())throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,this.getAuthRequiredMessage())}async resumeFromExistingDeposit(i){try{const e=await this.ctx.api.getDepositAddress({address:i,chainId:this.getChainId(),token:this.getExpectedToken(),partnerId:this.ctx.partner.getPartnerId()});return e?(this._depositAddress=e,!0):!1}catch{return!1}}async generateDepositAddressImpl(i){const e=this.getStatusConfig();return this.assertStatus(e.ready,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const n=this.getDepositAddressParams(i),a=await this.ctx.api.generateDepositAddress(n);m(a),this._depositAddress=a;const o=this.getInitialSteps(),h=Object.fromEntries(Object.entries(o).map(([d],C)=>[d,C===0?t.StepStatus.COMPLETE:t.StepStatus.IDLE]));return this.emitProgress({status:e.addressReady,steps:h,metadata:{depositAddress:a}}),a},e.addressReady)}async executeImpl(){const i=this.getStatusConfig();return this.act(async()=>{this.assertStatus(i.addressReady,"execute"),this._depositAddress||await this.generateDepositAddressImpl();const e=this.ensureDepositAddress(),n=await this.trySendBitcoin(e);return n?{depositAddress:e,txHash:n}:{depositAddress:e}})}emitInitialProgress(){this.emitProgress({status:this.status,steps:this.getInitialSteps()})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await N({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:a=>{this.emitProgress({status:this.status,steps:a.steps,confirmations:a.confirmations,requiredConfirmations:a.requiredConfirmations,metadata:{isClaimed:a.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}async trySendBitcoin(i){const e=this._amount;if(e)try{const n=await this.ctx.getProvider("bitcoin");if(!n)return;const a=n;if(a.sendBitcoin){const o=f.toSatoshi(e).toNumber();return a.sendBitcoin(i,o)}}catch{}}}function l(s,r=A.Token.LBTC){switch(s){case c.AssetId.LBTC:return A.Token.LBTC;case c.AssetId.BTCb:return A.Token.BTCb;default:return r}}async function et(s,r){try{await s.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${r.toString(16)}`}]})}catch(i){const e=i;if(e.code===4902)try{await A.addChain({provider:s,chainId:r}),await s.request({method:"wallet_switchEthereumChain",params:[{chainId:`0x${r.toString(16)}`}]});return}catch(n){const a=n;throw a.code===4001?new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"User rejected adding chain to wallet."):new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Failed to add chain ${r} to wallet: ${a.message||"Unknown error"}`)}throw e.code===4001?new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"User rejected chain switch request."):new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Failed to switch to chain ${r}: ${e.message||"Unknown error"}`)}}async function st(s){const r=await s.request({method:"eth_chainId"});return parseInt(r,16)}async function D(s,r){await st(s)!==r&&await et(s,r)}const it=[t.Chain.ETHEREUM,t.Chain.SEPOLIA],rt={async getMintingFee(s,r){return s.capabilities.require("evm").getMintingFee(r,A.Token.BTCb)},async restoreFeeSignature(s,r,i){const e=await I.getTokenContractInfo(A.Token.BTCb,r,s.env),n=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:e.address});return!n.hasSignature||n.expirationDate&&new Date(Number(n.expirationDate)*1e3)<new Date?null:{hasSignature:!0,signature:n.signature,typedData:n.typedData}},async authorizeFee(s,{chainId:r,recipient:i,fee:e}){const n=s.capabilities.require("evm"),a=await s.getProvider("evm");if(!a)throw t.LombardError.providerMissing(String(r),"evm");await D(a,r);const o=f.toSatoshi(e).toString(),h=await I.getTokenContractInfo(A.Token.BTCb,r,s.env),d=await n.signNetworkFee({fee:o,account:i,chainId:r,provider:a,token:A.Token.BTCb});return await s.api.storeFeeSignature({address:i,signature:d.signature,typedData:d.typedData,tokenAddress:h.address}),{signature:d.signature,typedData:d.typedData}}},at={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.BTCb).filter(s=>t.isEvmChain(s)),supportedAssetsOut:[c.AssetId.BTCb],addressSchema:t.evmAddressSchema,getFeeAuthConfig(s){return it.includes(s)?rt:null},async signDestination(s,r,i){const e=s.capabilities.require("evm"),n=await s.getProvider("evm");if(!n)throw t.LombardError.providerMissing(String(i),"evm");return await D(n,i),{signature:(await e.signLbtcDestination({address:r,chainId:i,provider:n})).signature}}},w=s=>`${s}${t.CAIP2_SEPARATOR}`;function nt(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.EIP155))}function b(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.SOLANA))}function ot(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.SUI))}function ut(s){return String(s).startsWith(w(t.CHAIN_PREFIXES.STARKNET))}function dt(s){const r={[t.Chain.SOLANA_MAINNET]:"mainnet-beta",[t.Chain.SOLANA_DEVNET]:"devnet",[t.Chain.SOLANA_TESTNET]:"testnet","solana:mainnet-beta":"mainnet-beta","solana:devnet":"devnet","solana:testnet":"testnet"},i=r[s];if(!i)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unknown Solana chain: ${s}. Expected one of: ${Object.keys(r).join(", ")}`);return i}const ct={chainType:"solana",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet]}],destChains:t.getAllAssetChains(c.AssetId.BTCb).filter(s=>b(s)),supportedAssetsOut:[c.AssetId.BTCb],addressSchema:t.solanaAddressSchema,getFeeAuthConfig:()=>null,async signDestination(s,r,i){const e=s.capabilities.require("solana"),n=dt(i),{signature:a}=await e.signLbtcDestination({network:n});return{signature:a}}},ht={evm:at,solana:ct};function pt(s){return ht[s]}function At(s,r){return s.destChains.includes(r)}function St(s,r){return s.supportedAssetsOut.includes(r)}function gt(s,r,i){return s.routes.some(e=>e.envs.includes(i)&&(!r||e.sourceChains.includes(r)))}class k extends T{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"config");p(this,"chainId");p(this,"authState",{authorized:!1});p(this,"feeAuthConfig",null);const n=t.getChainType(e.destChain),a=pt(n);if(!a)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported destination chain type: ${n} (${e.destChain})`);if(!St(a,e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for BTC deposits. BTC Deposit produces BTC.b. For LBTC, use BtcStake instead.`);if(!At(a,e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for ${n} BTC deposits`);if(!gt(a,e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});this.config=a,this.chainId=t.parseChainIdentifier(e.destChain)}getAddressSchema(){return this.config.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}get mintingFee(){return this.authState.mintingFee}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),eip712Data:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}async generateDepositAddress(i){if(!this.authState.signature){const e=await this.config.signDestination(this.ctx,this.ensureRecipient(),this.chainId);this.authState.signature=e.signature,this.authState.typedData=e.typedData}return this.generateDepositAddressImpl(i)}getExpectedToken(){return l(this.params.assetOut,A.Token.BTCb)}getAuthRequiredMessage(){return this.feeAuthConfig?"Fee authorization required. Call authorizeFee() first.":"Address confirmation required. Call confirmAddress() first."}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.feeAuthConfig=this.config.getFeeAuthConfig(this.params.destChain),await this.resumeFromExistingDeposit(e.recipient)){if(this.feeAuthConfig){const a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(!(a!=null&&a.hasSignature)){this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION),this.emitInitialProgress();return}a.signature&&(this.authState.signature=a.signature,this.authState.typedData=a.typedData),this.authState.authorized=!0}this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}if(this.feeAuthConfig){const a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(a!=null&&a.hasSignature){a.signature&&(this.authState.signature=a.signature,this.authState.typedData=a.typedData),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION)}else this.updateStatus(t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION);this.emitInitialProgress()})}async authorizeFee(){if(this.assertStatus([t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeFee"),this.status===t.BtcActionStatus.READY)return;if(!this.feeAuthConfig)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Fee authorization is not required for this destination chain. Use confirmAddress() instead.");const i=this.ensureRecipient();if(!this.authState.mintingFee)throw new t.LombardError(t.ValidationErrorCode.INVALID_STATE,"Minting fee not available. Call prepare() first.");return this.act(async()=>{const e=await this.feeAuthConfig.authorizeFee(this.ctx,{chainId:this.chainId,recipient:i,fee:this.authState.mintingFee});this.authState.signature=e.signature,this.authState.typedData=e.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async confirmAddress(){if(this.assertStatus([t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION,t.BtcActionStatus.READY],"confirmAddress"),this.status===t.BtcActionStatus.READY)return;if(this.feeAuthConfig)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"This destination chain requires fee authorization. Use authorizeFee() instead.");const i=this.ensureRecipient();return this.act(async()=>{const e=await this.config.signDestination(this.ctx,i,this.chainId);this.authState.signature=e.signature,this.authState.typedData=e.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async execute(){return this.executeImpl()}async monitorDeposit(){return super.monitorDeposit()}}const Ct=q.EARN_STAKE_AND_BAKE_CHAINS.map(s=>t.evmChainIdToChain(s)),Et={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:Ct,supportedAssetsOut:[c.AssetId.LBTC],supportedProtocols:Nt(c.AssetId.LBTC),addressSchema:t.evmAddressSchema,async getStakeAndBakeFee(s,r,i){return s.capabilities.require("evm").getStakeAndBakeFee(r,i)},async authorizeStakeAndBake(s,{chainId:r,recipient:i,amount:e,vaultKey:n,token:a}){const o=s.capabilities.require("evm"),h=await s.getProvider("evm");if(!h)throw t.LombardError.providerMissing(String(r),"evm");await D(h,r);const d=await o.signStakeAndBake({value:e,account:i,chainId:r,provider:h,vaultKey:n,token:a});return await s.api.storeStakeAndBakeSignature({signature:d.signature,typedData:d.typedData}),{signature:d.signature,typedData:d.typedData}},async restoreStakeAndBakeSignature(s,r,i){try{const e=await R.getUserStakeAndBakeSignature({userDestinationAddress:i,chainId:r,env:s.env});return!(e.signature||e.expirationDate)||e.expirationDate&&Number(e.expirationDate)*1e3<Date.now()?null:{hasSignature:!0,signature:e.signature,depositAmount:e.depositAmount,expirationDate:e.expirationDate}}catch{return null}}},g=Et;function Dt(s){return g.destChains.includes(s)}function lt(s){return g.supportedAssetsOut.includes(s)}function ft(s,r){return s?g.routes.some(i=>i.sourceChains.includes(s)&&i.envs.includes(r)):!0}function O(s){return s in c.DEFI_REGISTRY}function It(s){if(!O(s)){const r=Object.keys(c.DEFI_REGISTRY).join(", ");throw new Error(`Unsupported protocol: ${s}. Supported protocols: ${r}`)}return s}function mt(s){return Object.entries(c.DEFI_REGISTRY).filter(([r,i])=>s in i).map(([r])=>r)}const v={mainnet:[t.Chain.AVALANCHE],testnet:[t.Chain.AVALANCHE_FUJI]},Tt={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.stage,u.r.dev,u.r.testnet,u.r.ibc]}],destChains:[...v.mainnet,...v.testnet],supportedAssetsOut:[c.AssetId.BTCb],supportedProtocols:mt(c.AssetId.BTCb),addressSchema:t.evmAddressSchema,async getDepositAndDeployFee(s,r,i){return s.capabilities.require("evm").getStakeAndBakeFee(r,i)},async authorizeDepositAndDeploy(s,{chainId:r,recipient:i,amount:e,vaultKey:n,token:a}){const o=s.capabilities.require("evm"),h=await s.getProvider("evm");if(!h)throw t.LombardError.providerMissing(String(r),"evm");await D(h,r);const d=await o.signStakeAndBake({value:e,account:i,chainId:r,provider:h,vaultKey:n,token:a});return await s.api.storeStakeAndBakeSignature({signature:d.signature,typedData:d.typedData}),{signature:d.signature,typedData:d.typedData,approvalTxHash:d.approvalTxHash}}},E=Tt;function wt(s){return E.destChains.includes(s)}function yt(s){return E.supportedAssetsOut.includes(s)}function P(s){return s in c.DEFI_REGISTRY}function L(s){if(!P(s)){const r=Object.keys(c.DEFI_REGISTRY).join(", ");throw new Error(`Unsupported protocol: ${s}. Supported protocols: ${r}`)}return s}function Nt(s){return Object.entries(c.DEFI_REGISTRY).filter(([r,i])=>s in i).map(([r])=>r)}function _t(s,r){return E.routes.some(i=>i.sourceChains.includes(s)&&i.envs.includes(r))}class F extends T{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"chainId");p(this,"authState",{authorized:!1});if(!yt(e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for deposit and deploy. DepositAndDeploy produces BTC.b which is then deployed to a vault like Silo.`);if(!wt(e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for deposit and deploy. Supported chains: Avalanche, Avalanche Fuji`);if(!P(e.protocol))throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,`Protocol ${e.protocol} is not supported for deposit and deploy. DepositAndDeploy with BTC.b only supports Silo protocol.`);const n=e.sourceChain??t.Chain.BITCOIN_MAINNET;if(!_t(n,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:n,destChain:e.destChain,env:i.env});const a=t.parseChainIdentifier(e.destChain);if(typeof a!="number"||!A.isValidChain(a))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported EVM chain: ${e.destChain}`);this.chainId=a}getAddressSchema(){return E.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,wrapping:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),signatureData:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return l(this.params.assetOut,A.Token.BTCb)}getAuthRequiredMessage(){return"Deposit authorization required. Call authorizeDeposit() first."}get fee(){return this.authState.fee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.authState.fee=await E.getDepositAndDeployFee(this.ctx,this.chainId,L(this.params.protocol)),this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress()},t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION)}async authorizeDeposit(){if(this.assertStatus([t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeDeposit"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.ensureAmount();return this.act(async()=>{const n=f.toSatoshi(e),a=l(this.params.assetOut,A.Token.BTCb),o=await E.authorizeDepositAndDeploy(this.ctx,{chainId:this.chainId,recipient:i,amount:n.toString(),vaultKey:L(this.params.protocol),token:a});this.authState.signature=o.signature,this.authState.typedData=o.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){return this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const e=this.getDepositAddressParams(i),n=await this.ctx.api.generateDepositAddress(e);return m(n),this._depositAddress=n,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,wrapping:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE},metadata:{depositAddress:n}}),n},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.act(async()=>{this.assertStatus(t.BtcActionStatus.ADDRESS_READY,"execute"),this._depositAddress||await this.generateDepositAddress();const i=this.ensureDepositAddress(),e=await this.trySendBitcoin(i);return e?{depositAddress:i,txHash:e}:{depositAddress:i}})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await N({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:a=>{this.emitProgress({status:this.status,steps:{created:t.StepStatus.COMPLETE,verifying:a.hasEnoughConfirmations?t.StepStatus.COMPLETE:t.StepStatus.PENDING,wrapping:a.isClaimed?t.StepStatus.COMPLETE:t.StepStatus.PENDING,depositing:t.StepStatus.PENDING},confirmations:a.confirmations,requiredConfirmations:a.requiredConfirmations,metadata:{isClaimed:a.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}}const Bt=[t.Chain.ETHEREUM,t.Chain.SEPOLIA],vt={async getMintingFee(s,r){return s.capabilities.require("evm").getMintingFee(r)},async restoreFeeSignature(s,r,i){const e=await I.getTokenContractInfo(A.Token.LBTC,r,s.env),n=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:e.address});return!n.hasSignature||n.expirationDate&&new Date(Number(n.expirationDate)*1e3)<new Date?null:{hasSignature:!0,signature:n.signature,typedData:n.typedData}},async authorizeFee(s,{chainId:r,recipient:i,fee:e}){const n=s.capabilities.require("evm"),a=await s.getProvider("evm");if(!a)throw t.LombardError.providerMissing(String(r),"evm");await D(a,r);const o=f.toSatoshi(e).toString(),h=await I.getTokenContractInfo(A.Token.LBTC,r,s.env),d=await n.signNetworkFee({fee:o,account:i,chainId:r,provider:a,token:A.Token.LBTC});try{await s.api.storeFeeSignature({address:i,signature:d.signature,typedData:d.typedData,tokenAddress:h.address})}catch(C){if(!(C instanceof $.FeeSignatureAlreadyExistsError))throw C;const S=await s.api.getFeeSignature({address:i,chainId:r,tokenAddress:h.address});if(S!=null&&S.hasSignature)return{signature:S.signature??d.signature,typedData:S.typedData??d.typedData};throw new Error("A fee authorization signature already exists for this account but cannot be retrieved. Refresh the page and try again, or contact support if this persists.")}return{signature:d.signature,typedData:d.typedData}}},Lt={chainType:"evm",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>nt(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.evmAddressSchema,getFeeAuthConfig(s){return Bt.includes(s)?vt:null},async getSignature(s,r,i){const e=s.capabilities.require("evm"),n=await s.getProvider("evm");if(!n)throw t.LombardError.providerMissing(String(i),"evm");return await D(n,i),e.signLbtcDestination({chainId:i,address:r,provider:n})}};function Rt(s){const r={[t.Chain.SOLANA_MAINNET]:"mainnet-beta",[t.Chain.SOLANA_DEVNET]:"devnet",[t.Chain.SOLANA_TESTNET]:"testnet","solana:mainnet-beta":"mainnet-beta","solana:devnet":"devnet","solana:testnet":"testnet"},i=r[s];if(!i)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unknown Solana chain: ${s}. Expected one of: ${Object.keys(r).join(", ")}`);return i}const bt={chainType:"solana",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>b(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.solanaAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("solana"),n=Rt(i),{signature:a}=await e.signLbtcDestination({network:n});return{signature:a}}},kt={chainType:"starknet",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>ut(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.starknetAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("starknet"),{signature:n,pubKey:a}=await e.signLbtcDestination({chainId:i}),o=U.pad(r,{size:32});return{signature:n,pubKey:a,paddedAddress:o}}},Ot={chainType:"sui",routes:[{sourceChains:[t.Chain.BITCOIN_MAINNET],envs:[u.r.prod]},{sourceChains:[t.Chain.BITCOIN_SIGNET],envs:[u.r.testnet,u.r.stage,u.r.dev,u.r.ibc]}],destChains:t.getAllAssetChains(c.AssetId.LBTC).filter(s=>ot(s)),supportedAssetsOut:[c.AssetId.LBTC],addressSchema:t.suiAddressSchema,getFeeAuthConfig:()=>null,async getSignature(s,r,i){const e=s.capabilities.require("sui"),{signature:n}=await e.signLbtcDestination({chainId:i});return{signature:n}}},Pt={evm:Lt,solana:bt,sui:Ot,starknet:kt};function Ft(s){return Pt[s]}function xt(s,r,i){return r?s.routes.some(e=>e.sourceChains.includes(r)&&e.envs.includes(i)):!0}function Mt(s,r){return s.destChains.includes(r)}function Vt(s,r){return s.supportedAssetsOut.includes(r)}class x extends T{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"config");p(this,"chainId");p(this,"authState",{authorized:!1});p(this,"feeAuthConfig",null);const n=t.getChainType(e.destChain),a=Ft(n);if(!a)throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported destination chain type: ${n} (${e.destChain})`);if(!Vt(a,e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for BTC staking. BTC Stake produces LBTC. For BTC.b, use BtcDeposit instead.`);if(!Mt(a,e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for ${n}`);if(!xt(a,e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});this.config=a,this.chainId=t.parseChainIdentifier(e.destChain)}getAddressSchema(){return this.config.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){var a;const e=this.ensureRecipient(),n=this.getActiveSignature();if(!n)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Missing signature. Complete authorization first.");return{address:n.paddedAddress??e,chainId:this.chainId,signature:n.signature,token:this.getExpectedToken(),eip712Data:(a=this.authState.networkFee)==null?void 0:a.typedData,pubKey:n.pubKey,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return l(this.params.assetOut,A.Token.LBTC)}getAuthRequiredMessage(){return"Authorization required. Call authorize() first."}get mintingFee(){return this.authState.mintingFee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.feeAuthConfig=this.config.getFeeAuthConfig(this.params.destChain),await this.resumeFromExistingDeposit(e.recipient)){if(this.feeAuthConfig){const a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(!(a!=null&&a.hasSignature)){this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION),this.emitInitialProgress();return}a.signature&&(this.authState.networkFee={signature:a.signature,typedData:a.typedData}),this.authState.authorized=!0}this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}if(this.feeAuthConfig){const a=await this.feeAuthConfig.restoreFeeSignature(this.ctx,this.chainId,e.recipient);if(a!=null&&a.hasSignature){a.signature&&(this.authState.networkFee={signature:a.signature,typedData:a.typedData}),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.authState.mintingFee=await this.feeAuthConfig.getMintingFee(this.ctx,this.chainId),this.updateStatus(t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION)}else this.updateStatus(t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION);this.emitInitialProgress()})}async authorize(){if(this.assertStatus([t.BtcActionStatus.NEEDS_FEE_AUTHORIZATION,t.BtcActionStatus.NEEDS_ADDRESS_CONFIRMATION,t.BtcActionStatus.READY],"authorize"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.feeAuthConfig!==null;return this.act(async()=>{if(e){const n=this.ensureMintingFee(),a=await this.feeAuthConfig.authorizeFee(this.ctx,{chainId:this.chainId,recipient:i,fee:n});this.authState.networkFee={signature:a.signature,typedData:a.typedData}}else this.authState.destinationSignature=await this.config.getSignature(this.ctx,i,this.chainId);this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){if(this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress)return this._depositAddress;if(!this.getActiveSignature()){const e=await this.config.getSignature(this.ctx,this.ensureRecipient(),this.chainId);this.authState.destinationSignature=e}return this.act(async()=>{const e=this.getDepositAddressParams(i),n=await this.ctx.api.generateDepositAddress(e);return m(n),this._depositAddress=n,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE},metadata:{depositAddress:n}}),n},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.executeImpl()}async monitorDeposit(){return super.monitorDeposit()}ensureMintingFee(){if(!this.authState.mintingFee)throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,"Minting fee not fetched. Call prepare() first.");return this.authState.mintingFee}getActiveSignature(){var i;return(i=this.authState.networkFee)!=null&&i.signature?{signature:this.authState.networkFee.signature}:this.authState.destinationSignature}}class M extends T{constructor(i,e){super(i,e,t.BtcActionStatus.IDLE);p(this,"chainId");p(this,"authState",{authorized:!1});if(!lt(e.assetOut))throw new t.LombardError(t.ValidationErrorCode.INVALID_ASSET,`Asset ${e.assetOut} is not supported for stake and deploy. StakeAndDeploy produces LBTC which is then deployed to a vault.`);if(!Dt(e.destChain))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Destination chain ${e.destChain} is not supported for stake and deploy`);if(!O(e.protocol))throw new t.LombardError(t.ValidationErrorCode.INVALID_PARAMETER,`Protocol ${e.protocol} is not supported for stake and deploy`);if(!ft(e.sourceChain,i.env))throw t.LombardError.routeNotFound({assetOut:e.assetOut,sourceChain:e.sourceChain,destChain:e.destChain,env:i.env});const n=t.parseChainIdentifier(e.destChain);if(typeof n!="number"||!A.isValidChain(n))throw new t.LombardError(t.ValidationErrorCode.INVALID_CHAIN,`Unsupported EVM chain: ${e.destChain}`);this.chainId=n}getAddressSchema(){return g.addressSchema}getStatusConfig(){return{idle:t.BtcActionStatus.IDLE,ready:t.BtcActionStatus.READY,addressReady:t.BtcActionStatus.ADDRESS_READY}}getInitialSteps(){return{created:t.StepStatus.IDLE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE}}isAuthorized(){return this.authState.authorized}getChainId(){return this.chainId}getDepositAddressParams(i){return{address:this.ensureRecipient(),chainId:this.chainId,signature:this.authState.signature,token:this.getExpectedToken(),signatureData:this.authState.typedData,partnerId:this.ctx.partner.getPartnerId(),referrerCode:this._referralCode,captchaToken:i}}getExpectedToken(){return l(this.params.assetOut,A.Token.LBTC)}getAuthRequiredMessage(){return"Deposit authorization required. Call authorizeDeposit() first."}get fee(){return this.authState.fee}async prepare(i){return this.assertStatus(t.BtcActionStatus.IDLE,"prepare"),this.act(async()=>{const e=this.validatePrepareParams(i);if(this._amount=e.amount,this._recipient=e.recipient,this._referralCode=e.referralCode,this.authState.fee=await g.getStakeAndBakeFee(this.ctx,this.chainId,this.params.protocol),await this.resumeFromExistingDeposit(e.recipient)){const o=await g.restoreStakeAndBakeSignature(this.ctx,this.chainId,e.recipient);if(o!=null&&o.hasSignature){o.signature&&(this.authState.signature=o.signature),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.ADDRESS_READY),this.emitInitialProgress();return}this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress();return}const a=await g.restoreStakeAndBakeSignature(this.ctx,this.chainId,e.recipient);if(a!=null&&a.hasSignature){a.signature&&(this.authState.signature=a.signature),this.authState.authorized=!0,this.updateStatus(t.BtcActionStatus.READY),this.emitInitialProgress();return}this.updateStatus(t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION),this.emitInitialProgress()})}async authorizeDeposit(){if(this.assertStatus([t.BtcActionStatus.NEEDS_DEPLOY_AUTHORIZATION,t.BtcActionStatus.READY],"authorizeDeposit"),this.status===t.BtcActionStatus.READY)return;const i=this.ensureRecipient(),e=this.ensureAmount();return this.act(async()=>{const n=f.toSatoshi(e),a=this.params.assetIn??c.AssetId.BTC,o=await g.authorizeStakeAndBake(this.ctx,{chainId:this.chainId,recipient:i,amount:n.toString(),vaultKey:It(this.params.protocol),token:a});this.authState.signature=o.signature,this.authState.typedData=o.typedData,this.authState.authorized=!0},t.BtcActionStatus.READY)}async generateDepositAddress(i){return this.assertStatus(t.BtcActionStatus.READY,"generateDepositAddress"),this.ensureAuthorized(),this._depositAddress?this._depositAddress:this.act(async()=>{const e=this.getDepositAddressParams(i),n=await this.ctx.api.generateDepositAddress(e);return m(n),this._depositAddress=n,this.emitProgress({status:t.BtcActionStatus.ADDRESS_READY,steps:{created:t.StepStatus.COMPLETE,verifying:t.StepStatus.IDLE,issuing:t.StepStatus.IDLE,depositing:t.StepStatus.IDLE},metadata:{depositAddress:n}}),n},t.BtcActionStatus.ADDRESS_READY)}async execute(){return this.act(async()=>{this.assertStatus(t.BtcActionStatus.ADDRESS_READY,"execute"),this._depositAddress||await this.generateDepositAddress();const i=this.ensureDepositAddress(),e=await this.trySendBitcoin(i);return e?{depositAddress:i,txHash:e}:{depositAddress:i}})}async monitorDeposit(){const i=this._depositAddress,e=this._recipient;if(!i||!e)throw t.LombardError.missingParameter("depositAddress or recipient");return await N({network:this.bitcoinNetwork,btcService:this.ctx.btc,fetchDeposit:async()=>{const o=(await this.ctx.api.getDeposits(e)).find(h=>h.depositAddress===i);if(o)return{blockHeight:o.blockHeight,isClaimed:o.isClaimed}},onProgress:a=>{this.emitProgress({status:this.status,steps:{created:t.StepStatus.COMPLETE,verifying:a.hasEnoughConfirmations?t.StepStatus.COMPLETE:t.StepStatus.PENDING,issuing:a.isClaimed?t.StepStatus.COMPLETE:t.StepStatus.PENDING,depositing:t.StepStatus.PENDING},confirmations:a.confirmations,requiredConfirmations:a.requiredConfirmations,metadata:{isClaimed:a.isClaimed}})},onComplete:()=>{this.emitCompleted()}})}}class V{constructor(r){p(this,"ctx");this.ctx=t.createBtcCoreContext(r)}stake(r){return new x(this.ctx,r)}stakeAndDeploy(r){return new M(this.ctx,r)}deposit(r){return new k(this.ctx,r)}depositAndDeploy(r){return new F(this.ctx,r)}}function zt(s){return new V(s)}exports.BtcActions=V;exports.BtcDeposit=k;exports.BtcDepositAndDeploy=F;exports.BtcStake=x;exports.BtcStakeAndDeploy=M;exports.btcActions=zt;exports.btcModule=tt;
2
+ //# sourceMappingURL=BtcActions-CaoeJtse.cjs.map