@lombard.finance/sdk 4.1.2 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -0
- package/README.md +59 -10
- package/dist/api-functions/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.d.ts +5 -1
- package/dist/api-functions/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.d.ts.map +1 -1
- package/dist/api.cjs +2 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.js +41 -0
- package/dist/api.js.map +1 -0
- package/dist/bridge/lib/ccip-config.d.ts.map +1 -1
- package/dist/bridge.cjs +2 -0
- package/dist/bridge.cjs.map +1 -0
- package/dist/bridge.js +11 -0
- package/dist/bridge.js.map +1 -0
- package/dist/btc.cjs +2 -0
- package/dist/btc.cjs.map +1 -0
- package/dist/btc.js +13 -0
- package/dist/btc.js.map +1 -0
- package/dist/chains/btc/actions/deposit/config/index.d.ts +2 -1
- package/dist/chains/btc/actions/deposit/config/index.d.ts.map +1 -1
- package/dist/chains/btc/actions/deposit/config/types.d.ts +2 -1
- package/dist/chains/btc/actions/deposit/config/types.d.ts.map +1 -1
- package/dist/chains/btc/actions/depositAndDeploy/BtcDepositAndDeploy.d.ts +1 -1
- package/dist/chains/btc/actions/depositAndDeploy/BtcDepositAndDeploy.d.ts.map +1 -1
- package/dist/chains/btc/actions/depositAndDeploy/config/evm.d.ts.map +1 -1
- package/dist/chains/btc/actions/depositAndDeploy/config/index.d.ts +2 -1
- package/dist/chains/btc/actions/depositAndDeploy/config/index.d.ts.map +1 -1
- package/dist/chains/btc/actions/depositAndDeploy/config/types.d.ts +2 -1
- package/dist/chains/btc/actions/depositAndDeploy/config/types.d.ts.map +1 -1
- package/dist/chains/btc/actions/shared/validation.d.ts +2 -1
- package/dist/chains/btc/actions/shared/validation.d.ts.map +1 -1
- package/dist/chains/btc/actions/stake/config/evm.d.ts.map +1 -1
- package/dist/chains/btc/actions/stake/config/index.d.ts +2 -1
- package/dist/chains/btc/actions/stake/config/index.d.ts.map +1 -1
- package/dist/chains/btc/actions/stake/config/solana.d.ts.map +1 -1
- package/dist/chains/btc/actions/stake/config/starknet.d.ts.map +1 -1
- package/dist/chains/btc/actions/stake/config/sui.d.ts.map +1 -1
- package/dist/chains/btc/actions/stake/config/types.d.ts +2 -1
- package/dist/chains/btc/actions/stake/config/types.d.ts.map +1 -1
- package/dist/chains/btc/actions/stakeAndDeploy/BtcStakeAndDeploy.d.ts +1 -1
- package/dist/chains/btc/actions/stakeAndDeploy/BtcStakeAndDeploy.d.ts.map +1 -1
- package/dist/chains/btc/actions/stakeAndDeploy/config/evm.d.ts.map +1 -1
- package/dist/chains/btc/actions/stakeAndDeploy/config/index.d.ts +2 -1
- package/dist/chains/btc/actions/stakeAndDeploy/config/index.d.ts.map +1 -1
- package/dist/chains/btc/actions/stakeAndDeploy/config/types.d.ts +2 -1
- package/dist/chains/btc/actions/stakeAndDeploy/config/types.d.ts.map +1 -1
- package/dist/chains/evm/EvmActions.d.ts +39 -0
- package/dist/chains/evm/EvmActions.d.ts.map +1 -1
- package/dist/chains/evm/actions/deploy/config/evm.d.ts +2 -1
- package/dist/chains/evm/actions/deploy/config/evm.d.ts.map +1 -1
- package/dist/chains/evm/actions/deploy/config/types.d.ts +2 -1
- package/dist/chains/evm/actions/deploy/config/types.d.ts.map +1 -1
- package/dist/chains/evm/actions/deposit/config/evm.d.ts +2 -1
- package/dist/chains/evm/actions/deposit/config/evm.d.ts.map +1 -1
- package/dist/chains/evm/actions/deposit/config/types.d.ts +2 -1
- package/dist/chains/evm/actions/deposit/config/types.d.ts.map +1 -1
- package/dist/chains/evm/actions/index.d.ts +1 -0
- package/dist/chains/evm/actions/index.d.ts.map +1 -1
- package/dist/chains/evm/actions/redeem/config/evm.d.ts +2 -1
- package/dist/chains/evm/actions/redeem/config/evm.d.ts.map +1 -1
- package/dist/chains/evm/actions/redeem/config/types.d.ts +2 -1
- package/dist/chains/evm/actions/redeem/config/types.d.ts.map +1 -1
- package/dist/chains/evm/actions/stake/config/evm.d.ts +2 -1
- package/dist/chains/evm/actions/stake/config/evm.d.ts.map +1 -1
- package/dist/chains/evm/actions/stake/config/types.d.ts +2 -1
- package/dist/chains/evm/actions/stake/config/types.d.ts.map +1 -1
- package/dist/chains/evm/actions/unstake/config/evm.d.ts +2 -1
- package/dist/chains/evm/actions/unstake/config/evm.d.ts.map +1 -1
- package/dist/chains/evm/actions/unstake/config/types.d.ts +2 -1
- package/dist/chains/evm/actions/unstake/config/types.d.ts.map +1 -1
- package/dist/chains/evm/actions/withdraw/EvmCancelWithdraw.d.ts +27 -0
- package/dist/chains/evm/actions/withdraw/EvmCancelWithdraw.d.ts.map +1 -0
- package/dist/chains/evm/actions/withdraw/EvmWithdraw.d.ts +39 -0
- package/dist/chains/evm/actions/withdraw/EvmWithdraw.d.ts.map +1 -0
- package/dist/chains/evm/actions/withdraw/config/evm.d.ts +22 -0
- package/dist/chains/evm/actions/withdraw/config/evm.d.ts.map +1 -0
- package/dist/chains/evm/actions/withdraw/config/index.d.ts +8 -0
- package/dist/chains/evm/actions/withdraw/config/index.d.ts.map +1 -0
- package/dist/chains/evm/actions/withdraw/config/types.d.ts +31 -0
- package/dist/chains/evm/actions/withdraw/config/types.d.ts.map +1 -0
- package/dist/chains/evm/actions/withdraw/factory.d.ts +53 -0
- package/dist/chains/evm/actions/withdraw/factory.d.ts.map +1 -0
- package/dist/chains/evm/actions/withdraw/index.d.ts +12 -0
- package/dist/chains/evm/actions/withdraw/index.d.ts.map +1 -0
- package/dist/chains/evm/actions/withdraw/types.d.ts +87 -0
- package/dist/chains/evm/actions/withdraw/types.d.ts.map +1 -0
- package/dist/chains/evm/shared/feeAuth.d.ts +1 -1
- package/dist/chains/evm/shared/feeAuth.d.ts.map +1 -1
- package/dist/chains/solana/actions/unstake/config/btc.d.ts +2 -1
- package/dist/chains/solana/actions/unstake/config/btc.d.ts.map +1 -1
- package/dist/chains/solana/actions/unstake/config/solana.d.ts +2 -1
- package/dist/chains/solana/actions/unstake/config/solana.d.ts.map +1 -1
- package/dist/chains/solana/actions/unstake/config/types.d.ts +2 -1
- package/dist/chains/solana/actions/unstake/config/types.d.ts.map +1 -1
- package/dist/chains/starknet/actions/unstake/config/btc.d.ts +2 -1
- package/dist/chains/starknet/actions/unstake/config/btc.d.ts.map +1 -1
- package/dist/chains/starknet/actions/unstake/config/starknet.d.ts +2 -1
- package/dist/chains/starknet/actions/unstake/config/starknet.d.ts.map +1 -1
- package/dist/chains/starknet/actions/unstake/config/types.d.ts +2 -1
- package/dist/chains/starknet/actions/unstake/config/types.d.ts.map +1 -1
- package/dist/chains/sui/actions/unstake/config/btc.d.ts +2 -1
- package/dist/chains/sui/actions/unstake/config/btc.d.ts.map +1 -1
- package/dist/chains/sui/actions/unstake/config/sui.d.ts +2 -1
- package/dist/chains/sui/actions/unstake/config/sui.d.ts.map +1 -1
- package/dist/chains/sui/actions/unstake/config/types.d.ts +2 -1
- package/dist/chains/sui/actions/unstake/config/types.d.ts.map +1 -1
- package/dist/chunks/BtcActions-D9eBmDj6.cjs +2 -0
- package/dist/chunks/BtcActions-D9eBmDj6.cjs.map +1 -0
- package/dist/chunks/BtcActions-DGqmtxjd.js +1791 -0
- package/dist/chunks/BtcActions-DGqmtxjd.js.map +1 -0
- package/dist/chunks/EvmActions-BOwYPThp.cjs +2 -0
- package/dist/chunks/EvmActions-BOwYPThp.cjs.map +1 -0
- package/dist/chunks/EvmActions-MW5mNmqs.js +1351 -0
- package/dist/chunks/EvmActions-MW5mNmqs.js.map +1 -0
- package/dist/chunks/ReferralsClient-DUwyIUe3.cjs +2 -0
- package/dist/chunks/ReferralsClient-DUwyIUe3.cjs.map +1 -0
- package/dist/chunks/ReferralsClient-JjWLlIO4.js +462 -0
- package/dist/chunks/ReferralsClient-JjWLlIO4.js.map +1 -0
- package/dist/chunks/api-config-CtcP3TVl.js +35 -0
- package/dist/chunks/api-config-CtcP3TVl.js.map +1 -0
- package/dist/chunks/api-config-DkXqqfCK.cjs +2 -0
- package/dist/chunks/api-config-DkXqqfCK.cjs.map +1 -0
- package/dist/chunks/approveLBTC-CN6rJF6_.cjs +2 -0
- package/dist/chunks/approveLBTC-CN6rJF6_.cjs.map +1 -0
- package/dist/chunks/approveLBTC-DOP0wsm3.js +26 -0
- package/dist/chunks/approveLBTC-DOP0wsm3.js.map +1 -0
- package/dist/chunks/array-Cev6kyLJ.js +15 -0
- package/dist/chunks/array-Cev6kyLJ.js.map +1 -0
- package/dist/chunks/array-DKG6Pz4i.cjs +2 -0
- package/dist/chunks/array-DKG6Pz4i.cjs.map +1 -0
- package/dist/chunks/blockchain-identifier-DtIGGlIi.cjs +2 -0
- package/dist/chunks/blockchain-identifier-DtIGGlIi.cjs.map +1 -0
- package/dist/chunks/blockchain-identifier-PNEhu-QU.js +113 -0
- package/dist/chunks/blockchain-identifier-PNEhu-QU.js.map +1 -0
- package/dist/chunks/bridge-DkZMwO7c.cjs +12 -0
- package/dist/chunks/bridge-DkZMwO7c.cjs.map +1 -0
- package/dist/chunks/bridge-DyAiDpxD.js +693 -0
- package/dist/chunks/bridge-DyAiDpxD.js.map +1 -0
- package/dist/chunks/config-DqbLaiRi.cjs +2 -0
- package/dist/chunks/config-DqbLaiRi.cjs.map +1 -0
- package/dist/chunks/config-_8X_2sG4.js +374 -0
- package/dist/chunks/config-_8X_2sG4.js.map +1 -0
- package/dist/chunks/constants-BBK-JNcY.cjs +2 -0
- package/dist/chunks/constants-BBK-JNcY.cjs.map +1 -0
- package/dist/chunks/constants-CuT4axsy.js +5 -0
- package/dist/chunks/constants-CuT4axsy.js.map +1 -0
- package/dist/chunks/defi-registry-NGWlyxAY.cjs +2 -0
- package/dist/chunks/defi-registry-NGWlyxAY.cjs.map +1 -0
- package/dist/chunks/defi-registry-dhrQMy94.js +172 -0
- package/dist/chunks/defi-registry-dhrQMy94.js.map +1 -0
- package/dist/chunks/depositStatus-DeCO-K5Q.js +205 -0
- package/dist/chunks/depositStatus-DeCO-K5Q.js.map +1 -0
- package/dist/chunks/depositStatus-K6gky8zH.cjs +2 -0
- package/dist/chunks/depositStatus-K6gky8zH.cjs.map +1 -0
- package/dist/chunks/events-CLVUaKQS.js +996 -0
- package/dist/chunks/events-CLVUaKQS.js.map +1 -0
- package/dist/chunks/events-DIKZG4SZ.cjs +2 -0
- package/dist/chunks/events-DIKZG4SZ.cjs.map +1 -0
- package/dist/chunks/evm-by-btc-address-CwLiENtM.js +39 -0
- package/dist/chunks/evm-by-btc-address-CwLiENtM.js.map +1 -0
- package/dist/chunks/evm-by-btc-address-DiQoIWsr.cjs +2 -0
- package/dist/chunks/evm-by-btc-address-DiQoIWsr.cjs.map +1 -0
- package/dist/chunks/fee-requirements-CICSxYYL.cjs +2 -0
- package/dist/chunks/fee-requirements-CICSxYYL.cjs.map +1 -0
- package/dist/chunks/fee-requirements-x8-8mpJ7.js +14 -0
- package/dist/chunks/fee-requirements-x8-8mpJ7.js.map +1 -0
- package/dist/chunks/get-exchange-ratio-B0CNEGOB.js +20 -0
- package/dist/chunks/get-exchange-ratio-B0CNEGOB.js.map +1 -0
- package/dist/chunks/get-exchange-ratio-CM8W0jTw.cjs +2 -0
- package/dist/chunks/get-exchange-ratio-CM8W0jTw.cjs.map +1 -0
- package/dist/chunks/get-positions-summary-Cled5YPA.js +103 -0
- package/dist/chunks/get-positions-summary-Cled5YPA.js.map +1 -0
- package/dist/chunks/get-positions-summary-Co7RZBiK.cjs +2 -0
- package/dist/chunks/get-positions-summary-Co7RZBiK.cjs.map +1 -0
- package/dist/chunks/get-vault-tvl-Bydlvlrv.cjs +2 -0
- package/dist/chunks/get-vault-tvl-Bydlvlrv.cjs.map +1 -0
- package/dist/chunks/get-vault-tvl-DxjO9xDs.js +226 -0
- package/dist/chunks/get-vault-tvl-DxjO9xDs.js.map +1 -0
- package/dist/chunks/get-vault-withdrawals-CSQqKFB8.js +161 -0
- package/dist/chunks/get-vault-withdrawals-CSQqKFB8.js.map +1 -0
- package/dist/chunks/get-vault-withdrawals-DBA3ok0m.cjs +2 -0
- package/dist/chunks/get-vault-withdrawals-DBA3ok0m.cjs.map +1 -0
- package/dist/chunks/getSharesByAddress-CK2q7gBI.js +121 -0
- package/dist/chunks/getSharesByAddress-CK2q7gBI.js.map +1 -0
- package/dist/chunks/getSharesByAddress-De7as74h.cjs +2 -0
- package/dist/chunks/getSharesByAddress-De7as74h.cjs.map +1 -0
- package/dist/chunks/getUserStakeAndBakeSignature--XsK93Lb.cjs +2 -0
- package/dist/chunks/getUserStakeAndBakeSignature--XsK93Lb.cjs.map +1 -0
- package/dist/chunks/getUserStakeAndBakeSignature-2xPkL9v_.js +120 -0
- package/dist/chunks/getUserStakeAndBakeSignature-2xPkL9v_.js.map +1 -0
- package/dist/chunks/index-BKzxeh1Y.cjs +2 -0
- package/dist/chunks/index-BKzxeh1Y.cjs.map +1 -0
- package/dist/chunks/index-CfcQ_g3t.js +37 -0
- package/dist/chunks/index-CfcQ_g3t.js.map +1 -0
- package/dist/chunks/lbtc-addresses-NHg9Gk5y.js +10 -0
- package/dist/chunks/lbtc-addresses-NHg9Gk5y.js.map +1 -0
- package/dist/chunks/lbtc-addresses-bj--zuK9.cjs +2 -0
- package/dist/chunks/lbtc-addresses-bj--zuK9.cjs.map +1 -0
- package/dist/chunks/numbers-3LtmxfD8.cjs +2 -0
- package/dist/chunks/numbers-3LtmxfD8.cjs.map +1 -0
- package/dist/chunks/numbers-CM-lcmt4.js +15 -0
- package/dist/chunks/numbers-CM-lcmt4.js.map +1 -0
- package/dist/chunks/parameters-CDV-6Hk5.js +11 -0
- package/dist/chunks/parameters-CDV-6Hk5.js.map +1 -0
- package/dist/chunks/parameters-DK9cYCAH.cjs +2 -0
- package/dist/chunks/parameters-DK9cYCAH.cjs.map +1 -0
- package/dist/chunks/satoshi-CZEsHl5X.cjs +2 -0
- package/dist/chunks/satoshi-CZEsHl5X.cjs.map +1 -0
- package/dist/chunks/satoshi-Ch6y8aYG.js +19 -0
- package/dist/chunks/satoshi-Ch6y8aYG.js.map +1 -0
- package/dist/chunks/statusConstants-DTDi_4Go.cjs +2 -0
- package/dist/chunks/statusConstants-DTDi_4Go.cjs.map +1 -0
- package/dist/chunks/statusConstants-ZJia15m2.js +4446 -0
- package/dist/chunks/statusConstants-ZJia15m2.js.map +1 -0
- package/dist/chunks/storeNetworkFeeSignature-BZUZOxns.js +65 -0
- package/dist/chunks/storeNetworkFeeSignature-BZUZOxns.js.map +1 -0
- package/dist/chunks/storeNetworkFeeSignature-pV7xUOSo.cjs +2 -0
- package/dist/chunks/storeNetworkFeeSignature-pV7xUOSo.cjs.map +1 -0
- package/dist/chunks/time-I-BeyUkG.cjs +2 -0
- package/dist/chunks/time-I-BeyUkG.cjs.map +1 -0
- package/dist/chunks/time-QPeEEEnQ.js +24 -0
- package/dist/chunks/time-QPeEEEnQ.js.map +1 -0
- package/dist/chunks/token-addresses-D859i6tX.cjs +2 -0
- package/dist/chunks/token-addresses-D859i6tX.cjs.map +1 -0
- package/dist/chunks/token-addresses-DmAr89jP.js +579 -0
- package/dist/chunks/token-addresses-DmAr89jP.js.map +1 -0
- package/dist/chunks/tokens-Bw35TZqd.js +6663 -0
- package/dist/chunks/tokens-Bw35TZqd.js.map +1 -0
- package/dist/chunks/tokens-DLGMNeqZ.cjs +2 -0
- package/dist/chunks/tokens-DLGMNeqZ.cjs.map +1 -0
- package/dist/chunks/unstakeLBTC-CqZzj9WL.cjs +2 -0
- package/dist/chunks/unstakeLBTC-CqZzj9WL.cjs.map +1 -0
- package/dist/chunks/unstakeLBTC-Huy_ncVl.js +3866 -0
- package/dist/chunks/unstakeLBTC-Huy_ncVl.js.map +1 -0
- package/dist/chunks/withdraw-CVNVJ7-x.js +209 -0
- package/dist/chunks/withdraw-CVNVJ7-x.js.map +1 -0
- package/dist/chunks/withdraw-Z77x7Hj4.cjs +12 -0
- package/dist/chunks/withdraw-Z77x7Hj4.cjs.map +1 -0
- package/dist/client/ApiNamespace.d.ts +39 -0
- package/dist/client/ApiNamespace.d.ts.map +1 -1
- package/dist/client/createLombardSDK.d.ts.map +1 -1
- package/dist/clients/rpc-url-config.d.ts.map +1 -1
- package/dist/common/chains.d.ts.map +1 -1
- package/dist/common/feature-config.d.ts +7 -7
- package/dist/contracts.cjs +2 -0
- package/dist/contracts.cjs.map +1 -0
- package/dist/contracts.js +32 -0
- package/dist/contracts.js.map +1 -0
- package/dist/core/assets/catalog.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/types.d.ts +0 -4
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core.cjs +2 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.js +101 -0
- package/dist/core.js.map +1 -0
- package/dist/debug.cjs +2 -0
- package/dist/debug.cjs.map +1 -0
- package/dist/debug.js +7 -0
- package/dist/debug.js.map +1 -0
- package/dist/defi.cjs +2 -0
- package/dist/defi.cjs.map +1 -0
- package/dist/defi.js +14 -0
- package/dist/defi.js.map +1 -0
- package/dist/entries/api.d.ts +26 -0
- package/dist/entries/api.d.ts.map +1 -0
- package/dist/entries/bridge.d.ts +7 -0
- package/dist/entries/bridge.d.ts.map +1 -0
- package/dist/entries/btc.d.ts +11 -0
- package/dist/entries/btc.d.ts.map +1 -0
- package/dist/entries/contracts.d.ts +23 -0
- package/dist/entries/contracts.d.ts.map +1 -0
- package/dist/entries/core.d.ts +45 -0
- package/dist/entries/core.d.ts.map +1 -0
- package/dist/entries/debug.d.ts +9 -0
- package/dist/entries/debug.d.ts.map +1 -0
- package/dist/entries/defi.d.ts +7 -0
- package/dist/entries/defi.d.ts.map +1 -0
- package/dist/entries/evm.d.ts +17 -0
- package/dist/entries/evm.d.ts.map +1 -0
- package/dist/entries/metrics.d.ts +10 -0
- package/dist/entries/metrics.d.ts.map +1 -0
- package/dist/entries/utils.d.ts +21 -0
- package/dist/entries/utils.d.ts.map +1 -0
- package/dist/entries/vaults.d.ts +7 -0
- package/dist/entries/vaults.d.ts.map +1 -0
- package/dist/evm.cjs +2 -0
- package/dist/evm.cjs.map +1 -0
- package/dist/evm.js +48 -0
- package/dist/evm.js.map +1 -0
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +49 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +293 -267
- package/dist/index.js.map +1 -0
- package/dist/metrics.cjs +2 -0
- package/dist/metrics.cjs.map +1 -0
- package/dist/metrics.js +9 -0
- package/dist/metrics.js.map +1 -0
- package/dist/shared/errors.d.ts +14 -1
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/events.d.ts +25 -2
- package/dist/shared/events.d.ts.map +1 -1
- package/dist/tokens/token-addresses.d.ts +2 -2
- package/dist/tokens/token-addresses.d.ts.map +1 -1
- package/dist/utils.cjs +2 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.js +101 -0
- package/dist/utils.js.map +1 -0
- package/dist/vaults.cjs +2 -0
- package/dist/vaults.cjs.map +1 -0
- package/dist/vaults.js +18 -0
- package/dist/vaults.js.map +1 -0
- package/package.json +98 -6
- package/dist/ccip.cjs +0 -1
- package/dist/ccip.js +0 -149
- package/dist/index2.cjs +0 -66
- package/dist/index2.js +0 -48325
|
@@ -0,0 +1,1791 @@
|
|
|
1
|
+
var V = Object.defineProperty;
|
|
2
|
+
var U = (e, i, s) => i in e ? V(e, i, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[i] = s;
|
|
3
|
+
var D = (e, i, s) => U(e, typeof i != "symbol" ? i + "" : i, s);
|
|
4
|
+
import G from "axios";
|
|
5
|
+
import { T as S, a as K, q as b } from "./token-addresses-DmAr89jP.js";
|
|
6
|
+
import { q as o, L as u, V as c, y as j, C as g, A as Z, a3 as W, a4 as X, z as J, _ as N, g as y, n as Q, B as a, X as v, e as tt, a5 as et, a6 as R, a7 as st, a8 as it, a9 as rt, aa as nt, ab as at } from "./statusConstants-ZJia15m2.js";
|
|
7
|
+
import { r as h } from "./index-CfcQ_g3t.js";
|
|
8
|
+
import { g as _ } from "./tokens-Bw35TZqd.js";
|
|
9
|
+
import { t as T } from "./satoshi-Ch6y8aYG.js";
|
|
10
|
+
import { A as f, b as I } from "./defi-registry-dhrQMy94.js";
|
|
11
|
+
import { S as ot, a as ut } from "./getUserStakeAndBakeSignature-2xPkL9v_.js";
|
|
12
|
+
import { V as dt } from "./config-_8X_2sG4.js";
|
|
13
|
+
import { pad as ht } from "viem";
|
|
14
|
+
const ct = "ERR_NETWORK", pt = "This may be due to your Adblocker. Please disable any Adblocker and refresh the page to restore full functionality.";
|
|
15
|
+
function gt(e) {
|
|
16
|
+
const { code: i, message: s } = e;
|
|
17
|
+
throw i === ct ? new Error(pt) : new Error(s);
|
|
18
|
+
}
|
|
19
|
+
const At = {
|
|
20
|
+
mempoolApiUrl: "https://mempool.space/signet"
|
|
21
|
+
}, Dt = {
|
|
22
|
+
mempoolApiUrl: "https://mempool.space"
|
|
23
|
+
}, ft = (e) => e === "mainnet" ? Dt : At;
|
|
24
|
+
async function St(e) {
|
|
25
|
+
const { mempoolApiUrl: i } = ft(e), s = Math.floor(Date.now() / 1e3), t = `${i}/api/v1/mining/blocks/timestamp/${s}`;
|
|
26
|
+
try {
|
|
27
|
+
const { data: n } = await G.get(t);
|
|
28
|
+
return n.height;
|
|
29
|
+
} catch (n) {
|
|
30
|
+
gt(n);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
class lt {
|
|
34
|
+
/**
|
|
35
|
+
* Get current block height from mempool
|
|
36
|
+
*/
|
|
37
|
+
async getCurrentBlockHeight(i) {
|
|
38
|
+
return St(i);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function Se() {
|
|
42
|
+
return {
|
|
43
|
+
id: "btc",
|
|
44
|
+
chain: "btc",
|
|
45
|
+
register() {
|
|
46
|
+
return new lt();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async function B(e) {
|
|
51
|
+
const {
|
|
52
|
+
fetchDeposit: i,
|
|
53
|
+
network: s,
|
|
54
|
+
btcService: t,
|
|
55
|
+
requiredConfirmations: n = 6,
|
|
56
|
+
onProgress: r,
|
|
57
|
+
onComplete: d
|
|
58
|
+
} = e, A = await i();
|
|
59
|
+
if (!A)
|
|
60
|
+
return;
|
|
61
|
+
const p = A.blockHeight;
|
|
62
|
+
if (typeof p != "number")
|
|
63
|
+
return;
|
|
64
|
+
const q = await t.getCurrentBlockHeight(s), F = Math.max(0, q - p), x = F >= n, k = A.isClaimed ?? !1, M = {
|
|
65
|
+
confirmations: F,
|
|
66
|
+
requiredConfirmations: n,
|
|
67
|
+
hasEnoughConfirmations: x,
|
|
68
|
+
isClaimed: k,
|
|
69
|
+
steps: {
|
|
70
|
+
created: o.COMPLETE,
|
|
71
|
+
verifying: x ? o.COMPLETE : o.PENDING,
|
|
72
|
+
issuing: k ? o.COMPLETE : o.PENDING
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
return r == null || r(M), k && (d == null || d()), M;
|
|
76
|
+
}
|
|
77
|
+
function O(e) {
|
|
78
|
+
if (e === ot)
|
|
79
|
+
throw new u(
|
|
80
|
+
c.INVALID_PARAMETER,
|
|
81
|
+
"Destination address is under sanctions"
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
class P extends j {
|
|
85
|
+
constructor(s, t, n) {
|
|
86
|
+
super(n);
|
|
87
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
88
|
+
// Common State
|
|
89
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
90
|
+
D(this, "_amount");
|
|
91
|
+
D(this, "_recipient");
|
|
92
|
+
D(this, "_depositAddress");
|
|
93
|
+
D(this, "_referralCode");
|
|
94
|
+
D(this, "_chainId");
|
|
95
|
+
this.ctx = s, this.params = t;
|
|
96
|
+
}
|
|
97
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
98
|
+
// Common Getters
|
|
99
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
100
|
+
/** Amount of BTC to stake/deposit */
|
|
101
|
+
get amount() {
|
|
102
|
+
return this._amount;
|
|
103
|
+
}
|
|
104
|
+
/** Recipient address on destination chain */
|
|
105
|
+
get recipient() {
|
|
106
|
+
return this._recipient;
|
|
107
|
+
}
|
|
108
|
+
/** Generated Bitcoin deposit address */
|
|
109
|
+
get depositAddress() {
|
|
110
|
+
return this._depositAddress;
|
|
111
|
+
}
|
|
112
|
+
/** Referral code (optional) */
|
|
113
|
+
get referralCode() {
|
|
114
|
+
return this._referralCode;
|
|
115
|
+
}
|
|
116
|
+
/** Bitcoin network mode for monitoring */
|
|
117
|
+
get bitcoinNetwork() {
|
|
118
|
+
return this.params.sourceChain === g.BITCOIN_MAINNET ? "mainnet" : "testnet";
|
|
119
|
+
}
|
|
120
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
121
|
+
// Common Validation
|
|
122
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
123
|
+
/**
|
|
124
|
+
* Get the prepare schema (amount + recipient + referralCode)
|
|
125
|
+
* Uses abstract getAddressSchema() for chain-specific validation
|
|
126
|
+
*/
|
|
127
|
+
get prepareSchema() {
|
|
128
|
+
return Z({
|
|
129
|
+
amount: X,
|
|
130
|
+
recipient: this.getAddressSchema(),
|
|
131
|
+
referralCode: W
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Validate prepare params using Zod
|
|
136
|
+
* Subclasses can override if they need custom validation
|
|
137
|
+
*/
|
|
138
|
+
validatePrepareParams(s) {
|
|
139
|
+
return J(this.prepareSchema, s, {
|
|
140
|
+
destChain: this.params.destChain
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
144
|
+
// Ensure Methods (throw if missing)
|
|
145
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
146
|
+
ensureRecipient() {
|
|
147
|
+
if (!this._recipient)
|
|
148
|
+
throw u.missingParameter("recipient");
|
|
149
|
+
return this._recipient;
|
|
150
|
+
}
|
|
151
|
+
ensureAmount() {
|
|
152
|
+
if (!this._amount)
|
|
153
|
+
throw u.missingParameter("amount");
|
|
154
|
+
return this._amount;
|
|
155
|
+
}
|
|
156
|
+
ensureDepositAddress() {
|
|
157
|
+
if (!this._depositAddress)
|
|
158
|
+
throw new u(
|
|
159
|
+
c.INVALID_PARAMETER,
|
|
160
|
+
"Deposit address not generated. Call generateDepositAddress() first."
|
|
161
|
+
);
|
|
162
|
+
return this._depositAddress;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get error message for missing authorization
|
|
166
|
+
* Subclasses can override to provide specific messages
|
|
167
|
+
*/
|
|
168
|
+
getAuthRequiredMessage() {
|
|
169
|
+
return "Authorization required. Complete the authorization step first.";
|
|
170
|
+
}
|
|
171
|
+
ensureAuthorized() {
|
|
172
|
+
if (!this.isAuthorized())
|
|
173
|
+
throw new u(
|
|
174
|
+
c.INVALID_PARAMETER,
|
|
175
|
+
this.getAuthRequiredMessage()
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
179
|
+
// Common Resume Logic
|
|
180
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
181
|
+
/**
|
|
182
|
+
* Try to resume from an existing deposit address
|
|
183
|
+
*
|
|
184
|
+
* This method only stores the deposit address if found.
|
|
185
|
+
* It does NOT update the status - the caller must do that
|
|
186
|
+
* after performing any additional validation (e.g., fee authorization).
|
|
187
|
+
*
|
|
188
|
+
* @param recipient - The recipient address to check
|
|
189
|
+
* @returns true if a deposit address was found, false otherwise
|
|
190
|
+
*/
|
|
191
|
+
async resumeFromExistingDeposit(s) {
|
|
192
|
+
try {
|
|
193
|
+
const t = await this.ctx.api.getDepositAddress({
|
|
194
|
+
address: s,
|
|
195
|
+
chainId: this.getChainId(),
|
|
196
|
+
token: this.getExpectedToken(),
|
|
197
|
+
partnerId: this.ctx.partner.getPartnerId()
|
|
198
|
+
});
|
|
199
|
+
return t ? (this._depositAddress = t, !0) : !1;
|
|
200
|
+
} catch {
|
|
201
|
+
return !1;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
205
|
+
// Common Generate Deposit Address
|
|
206
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
207
|
+
/**
|
|
208
|
+
* Generate a Bitcoin deposit address
|
|
209
|
+
*
|
|
210
|
+
* Template method that:
|
|
211
|
+
* 1. Validates status and authorization
|
|
212
|
+
* 2. Calls API to generate address
|
|
213
|
+
* 3. Updates state and emits progress
|
|
214
|
+
*
|
|
215
|
+
* Subclasses must implement getDepositAddressParams() to provide API params.
|
|
216
|
+
*/
|
|
217
|
+
async generateDepositAddressImpl() {
|
|
218
|
+
const s = this.getStatusConfig();
|
|
219
|
+
return this.assertStatus(s.ready, "generateDepositAddress"), this.ensureAuthorized(), this._depositAddress ? this._depositAddress : this.act(async () => {
|
|
220
|
+
const t = this.getDepositAddressParams(), n = await this.ctx.api.generateDepositAddress(t);
|
|
221
|
+
O(n), this._depositAddress = n;
|
|
222
|
+
const r = this.getInitialSteps(), d = Object.fromEntries(
|
|
223
|
+
Object.entries(r).map(([A], p) => [
|
|
224
|
+
A,
|
|
225
|
+
p === 0 ? o.COMPLETE : o.IDLE
|
|
226
|
+
])
|
|
227
|
+
);
|
|
228
|
+
return this.emitProgress({
|
|
229
|
+
status: s.addressReady,
|
|
230
|
+
steps: d,
|
|
231
|
+
metadata: { depositAddress: n }
|
|
232
|
+
}), n;
|
|
233
|
+
}, s.addressReady);
|
|
234
|
+
}
|
|
235
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
236
|
+
// Common Execute Pattern
|
|
237
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
238
|
+
/**
|
|
239
|
+
* Execute the action - generate address and optionally send BTC
|
|
240
|
+
*
|
|
241
|
+
* Template method that:
|
|
242
|
+
* 1. Ensures deposit address exists
|
|
243
|
+
* 2. Tries to send BTC if provider available
|
|
244
|
+
* 3. Returns result
|
|
245
|
+
*/
|
|
246
|
+
async executeImpl() {
|
|
247
|
+
const s = this.getStatusConfig();
|
|
248
|
+
return this.act(async () => {
|
|
249
|
+
this.assertStatus(s.addressReady, "execute"), this._depositAddress || await this.generateDepositAddressImpl();
|
|
250
|
+
const t = this.ensureDepositAddress(), n = await this.trySendBitcoin(t);
|
|
251
|
+
return n ? { depositAddress: t, txHash: n } : { depositAddress: t };
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
255
|
+
// Common Progress Emission
|
|
256
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
257
|
+
/**
|
|
258
|
+
* Emit initial progress with action-specific steps
|
|
259
|
+
*/
|
|
260
|
+
emitInitialProgress() {
|
|
261
|
+
this.emitProgress({
|
|
262
|
+
status: this.status,
|
|
263
|
+
steps: this.getInitialSteps()
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
267
|
+
// Deposit Monitoring
|
|
268
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
269
|
+
/**
|
|
270
|
+
* Monitor Bitcoin deposit progress
|
|
271
|
+
*/
|
|
272
|
+
async monitorDeposit() {
|
|
273
|
+
const s = this._depositAddress, t = this._recipient;
|
|
274
|
+
if (!s || !t)
|
|
275
|
+
throw u.missingParameter("depositAddress or recipient");
|
|
276
|
+
return await B({
|
|
277
|
+
network: this.bitcoinNetwork,
|
|
278
|
+
btcService: this.ctx.btc,
|
|
279
|
+
fetchDeposit: async () => {
|
|
280
|
+
const d = (await this.ctx.api.getDeposits(t)).find(
|
|
281
|
+
(A) => A.depositAddress === s
|
|
282
|
+
);
|
|
283
|
+
if (d)
|
|
284
|
+
return {
|
|
285
|
+
blockHeight: d.blockHeight,
|
|
286
|
+
isClaimed: d.isClaimed
|
|
287
|
+
};
|
|
288
|
+
},
|
|
289
|
+
onProgress: (r) => {
|
|
290
|
+
this.emitProgress({
|
|
291
|
+
status: this.status,
|
|
292
|
+
steps: r.steps,
|
|
293
|
+
confirmations: r.confirmations,
|
|
294
|
+
requiredConfirmations: r.requiredConfirmations,
|
|
295
|
+
metadata: { isClaimed: r.isClaimed }
|
|
296
|
+
});
|
|
297
|
+
},
|
|
298
|
+
onComplete: () => {
|
|
299
|
+
this.emitCompleted();
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
304
|
+
// Bitcoin Send (Optional)
|
|
305
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
306
|
+
async trySendBitcoin(s) {
|
|
307
|
+
const t = this._amount;
|
|
308
|
+
if (t)
|
|
309
|
+
try {
|
|
310
|
+
const n = await this.ctx.getProvider("bitcoin");
|
|
311
|
+
if (!n) return;
|
|
312
|
+
const r = n;
|
|
313
|
+
if (r.sendBitcoin) {
|
|
314
|
+
const d = T(t).toNumber();
|
|
315
|
+
return r.sendBitcoin(s, d);
|
|
316
|
+
}
|
|
317
|
+
} catch {
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function w(e, i = S.LBTC) {
|
|
322
|
+
switch (e) {
|
|
323
|
+
case f.LBTC:
|
|
324
|
+
return S.LBTC;
|
|
325
|
+
case f.BTCb:
|
|
326
|
+
return S.BTCb;
|
|
327
|
+
default:
|
|
328
|
+
return i;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
async function Ct(e, i) {
|
|
332
|
+
try {
|
|
333
|
+
await e.request({
|
|
334
|
+
method: "wallet_switchEthereumChain",
|
|
335
|
+
params: [{ chainId: `0x${i.toString(16)}` }]
|
|
336
|
+
});
|
|
337
|
+
} catch (s) {
|
|
338
|
+
const t = s;
|
|
339
|
+
if (t.code === 4902)
|
|
340
|
+
try {
|
|
341
|
+
await K({ provider: e, chainId: i }), await e.request({
|
|
342
|
+
method: "wallet_switchEthereumChain",
|
|
343
|
+
params: [{ chainId: `0x${i.toString(16)}` }]
|
|
344
|
+
});
|
|
345
|
+
return;
|
|
346
|
+
} catch (n) {
|
|
347
|
+
const r = n;
|
|
348
|
+
throw r.code === 4001 ? new u(
|
|
349
|
+
c.INVALID_PARAMETER,
|
|
350
|
+
"User rejected adding chain to wallet."
|
|
351
|
+
) : new u(
|
|
352
|
+
c.INVALID_CHAIN,
|
|
353
|
+
`Failed to add chain ${i} to wallet: ${r.message || "Unknown error"}`
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
throw t.code === 4001 ? new u(
|
|
357
|
+
c.INVALID_PARAMETER,
|
|
358
|
+
"User rejected chain switch request."
|
|
359
|
+
) : new u(
|
|
360
|
+
c.INVALID_CHAIN,
|
|
361
|
+
`Failed to switch to chain ${i}: ${t.message || "Unknown error"}`
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
async function Et(e) {
|
|
366
|
+
const i = await e.request({
|
|
367
|
+
method: "eth_chainId"
|
|
368
|
+
});
|
|
369
|
+
return parseInt(i, 16);
|
|
370
|
+
}
|
|
371
|
+
async function m(e, i) {
|
|
372
|
+
await Et(e) !== i && await Ct(e, i);
|
|
373
|
+
}
|
|
374
|
+
const It = [g.ETHEREUM, g.SEPOLIA], mt = {
|
|
375
|
+
async getMintingFee(e, i) {
|
|
376
|
+
return e.capabilities.require("evm").getMintingFee(i, S.BTCb);
|
|
377
|
+
},
|
|
378
|
+
async restoreFeeSignature(e, i, s) {
|
|
379
|
+
const t = await _(
|
|
380
|
+
S.BTCb,
|
|
381
|
+
i,
|
|
382
|
+
e.env
|
|
383
|
+
), n = await e.api.getFeeSignature({
|
|
384
|
+
address: s,
|
|
385
|
+
chainId: i,
|
|
386
|
+
tokenAddress: t.address
|
|
387
|
+
});
|
|
388
|
+
return !n.hasSignature || n.expirationDate && new Date(Number(n.expirationDate) * 1e3) < /* @__PURE__ */ new Date() ? null : {
|
|
389
|
+
hasSignature: !0,
|
|
390
|
+
signature: n.signature,
|
|
391
|
+
// May be undefined - that's OK
|
|
392
|
+
typedData: n.typedData
|
|
393
|
+
};
|
|
394
|
+
},
|
|
395
|
+
async authorizeFee(e, { chainId: i, recipient: s, fee: t }) {
|
|
396
|
+
const n = e.capabilities.require("evm"), r = await e.getProvider("evm");
|
|
397
|
+
if (!r)
|
|
398
|
+
throw u.providerMissing(String(i), "evm");
|
|
399
|
+
await m(r, i);
|
|
400
|
+
const d = T(t).toString(), A = await _(
|
|
401
|
+
S.BTCb,
|
|
402
|
+
i,
|
|
403
|
+
e.env
|
|
404
|
+
), p = await n.signNetworkFee({
|
|
405
|
+
fee: d,
|
|
406
|
+
account: s,
|
|
407
|
+
chainId: i,
|
|
408
|
+
provider: r,
|
|
409
|
+
token: S.BTCb
|
|
410
|
+
});
|
|
411
|
+
return await e.api.storeFeeSignature({
|
|
412
|
+
address: s,
|
|
413
|
+
signature: p.signature,
|
|
414
|
+
typedData: p.typedData,
|
|
415
|
+
tokenAddress: A.address
|
|
416
|
+
}), {
|
|
417
|
+
signature: p.signature,
|
|
418
|
+
typedData: p.typedData
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
}, wt = {
|
|
422
|
+
chainType: "evm",
|
|
423
|
+
routes: [
|
|
424
|
+
{
|
|
425
|
+
sourceChains: [g.BITCOIN_MAINNET],
|
|
426
|
+
envs: [h.prod]
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
sourceChains: [g.BITCOIN_SIGNET],
|
|
430
|
+
envs: [h.stage, h.dev, h.testnet, h.ibc]
|
|
431
|
+
}
|
|
432
|
+
],
|
|
433
|
+
// Derived from ASSET_CATALOG - all chains where BTC.b is deployed
|
|
434
|
+
destChains: y(f.BTCb).filter(
|
|
435
|
+
(e) => Q(e)
|
|
436
|
+
),
|
|
437
|
+
// BTC Deposit only produces BTC.b
|
|
438
|
+
supportedAssetsOut: [f.BTCb],
|
|
439
|
+
addressSchema: N,
|
|
440
|
+
/**
|
|
441
|
+
* Get fee auth config - unsubsidized chains require fee authorization
|
|
442
|
+
* Other chains use address confirmation signing
|
|
443
|
+
*/
|
|
444
|
+
getFeeAuthConfig(e) {
|
|
445
|
+
return It.includes(e) ? mt : null;
|
|
446
|
+
},
|
|
447
|
+
/**
|
|
448
|
+
* Sign destination address confirmation
|
|
449
|
+
* Used for non-fee-auth chains (e.g., Avalanche, Katana)
|
|
450
|
+
*/
|
|
451
|
+
async signDestination(e, i, s) {
|
|
452
|
+
const t = e.capabilities.require("evm"), n = await e.getProvider("evm");
|
|
453
|
+
if (!n)
|
|
454
|
+
throw u.providerMissing(String(s), "evm");
|
|
455
|
+
return await m(n, s), {
|
|
456
|
+
signature: (await t.signLbtcDestination({
|
|
457
|
+
address: i,
|
|
458
|
+
chainId: s,
|
|
459
|
+
provider: n
|
|
460
|
+
})).signature
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
}, C = wt;
|
|
464
|
+
function yt(e) {
|
|
465
|
+
return C.destChains.includes(e);
|
|
466
|
+
}
|
|
467
|
+
function Tt(e) {
|
|
468
|
+
return C.supportedAssetsOut.includes(e);
|
|
469
|
+
}
|
|
470
|
+
function _t(e, i) {
|
|
471
|
+
return e ? C.routes.some(
|
|
472
|
+
(s) => s.sourceChains.includes(e) && s.envs.includes(i)
|
|
473
|
+
) : !0;
|
|
474
|
+
}
|
|
475
|
+
class Nt extends P {
|
|
476
|
+
constructor(s, t) {
|
|
477
|
+
super(s, t, a.IDLE);
|
|
478
|
+
D(this, "chainId");
|
|
479
|
+
D(this, "authState", { authorized: !1 });
|
|
480
|
+
/** Fee auth config - null if not required for this destination */
|
|
481
|
+
D(this, "feeAuthConfig", null);
|
|
482
|
+
if (!Tt(t.assetOut))
|
|
483
|
+
throw new u(
|
|
484
|
+
c.INVALID_ASSET,
|
|
485
|
+
`Asset ${t.assetOut} is not supported for BTC deposits. BTC Deposit produces BTC.b. For LBTC, use BtcStake instead.`
|
|
486
|
+
);
|
|
487
|
+
if (!yt(t.destChain))
|
|
488
|
+
throw new u(
|
|
489
|
+
c.INVALID_CHAIN,
|
|
490
|
+
`Destination chain ${t.destChain} is not supported for BTC deposits. BTC.b is currently available on Avalanche and Katana.`
|
|
491
|
+
);
|
|
492
|
+
if (!_t(t.sourceChain, s.env))
|
|
493
|
+
throw u.routeNotFound({
|
|
494
|
+
assetOut: t.assetOut,
|
|
495
|
+
sourceChain: t.sourceChain,
|
|
496
|
+
destChain: t.destChain,
|
|
497
|
+
env: s.env
|
|
498
|
+
});
|
|
499
|
+
const n = v(t.destChain);
|
|
500
|
+
if (typeof n != "number" || !b(n))
|
|
501
|
+
throw new u(
|
|
502
|
+
c.INVALID_CHAIN,
|
|
503
|
+
`Unsupported EVM chain: ${t.destChain}`
|
|
504
|
+
);
|
|
505
|
+
this.chainId = n;
|
|
506
|
+
}
|
|
507
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
508
|
+
// Abstract Method Implementations
|
|
509
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
510
|
+
getAddressSchema() {
|
|
511
|
+
return C.addressSchema;
|
|
512
|
+
}
|
|
513
|
+
getStatusConfig() {
|
|
514
|
+
return {
|
|
515
|
+
idle: a.IDLE,
|
|
516
|
+
ready: a.READY,
|
|
517
|
+
addressReady: a.ADDRESS_READY
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
getInitialSteps() {
|
|
521
|
+
return {
|
|
522
|
+
created: o.IDLE,
|
|
523
|
+
verifying: o.IDLE,
|
|
524
|
+
issuing: o.IDLE
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
isAuthorized() {
|
|
528
|
+
return this.authState.authorized;
|
|
529
|
+
}
|
|
530
|
+
getChainId() {
|
|
531
|
+
return this.chainId;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Get the minting fee for this deposit (in BTC)
|
|
535
|
+
* Available after prepare() when fee authorization is required
|
|
536
|
+
*/
|
|
537
|
+
get mintingFee() {
|
|
538
|
+
return this.authState.mintingFee;
|
|
539
|
+
}
|
|
540
|
+
getDepositAddressParams() {
|
|
541
|
+
return {
|
|
542
|
+
address: this.ensureRecipient(),
|
|
543
|
+
chainId: this.chainId,
|
|
544
|
+
signature: this.authState.signature,
|
|
545
|
+
// Must be set before calling
|
|
546
|
+
token: this.getExpectedToken(),
|
|
547
|
+
eip712Data: this.authState.typedData,
|
|
548
|
+
partnerId: this.ctx.partner.getPartnerId(),
|
|
549
|
+
referrerCode: this._referralCode
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Override to ensure we have a signature before generating deposit address.
|
|
554
|
+
*
|
|
555
|
+
* When fee auth exists on server but signature isn't available locally,
|
|
556
|
+
* we fall back to signing the destination address.
|
|
557
|
+
*/
|
|
558
|
+
async generateDepositAddress() {
|
|
559
|
+
if (!this.authState.signature) {
|
|
560
|
+
const s = await C.signDestination(
|
|
561
|
+
this.ctx,
|
|
562
|
+
this.ensureRecipient(),
|
|
563
|
+
this.chainId
|
|
564
|
+
);
|
|
565
|
+
this.authState.signature = s.signature, this.authState.typedData = s.typedData;
|
|
566
|
+
}
|
|
567
|
+
return this.generateDepositAddressImpl();
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Get expected token for this action (BTCb by default for BTC Deposit)
|
|
571
|
+
*/
|
|
572
|
+
getExpectedToken() {
|
|
573
|
+
return w(this.params.assetOut, S.BTCb);
|
|
574
|
+
}
|
|
575
|
+
getAuthRequiredMessage() {
|
|
576
|
+
return this.feeAuthConfig ? "Fee authorization required. Call authorizeFee() first." : "Address confirmation required. Call confirmAddress() first.";
|
|
577
|
+
}
|
|
578
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
579
|
+
// Public Methods
|
|
580
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
581
|
+
async prepare(s) {
|
|
582
|
+
return this.assertStatus(a.IDLE, "prepare"), this.act(async () => {
|
|
583
|
+
const t = this.validatePrepareParams(s);
|
|
584
|
+
if (this._amount = t.amount, this._recipient = t.recipient, this._referralCode = t.referralCode, this.feeAuthConfig = C.getFeeAuthConfig(
|
|
585
|
+
this.params.destChain
|
|
586
|
+
), await this.resumeFromExistingDeposit(
|
|
587
|
+
t.recipient
|
|
588
|
+
)) {
|
|
589
|
+
if (this.feeAuthConfig) {
|
|
590
|
+
const r = await this.feeAuthConfig.restoreFeeSignature(
|
|
591
|
+
this.ctx,
|
|
592
|
+
this.chainId,
|
|
593
|
+
t.recipient
|
|
594
|
+
);
|
|
595
|
+
if (!(r != null && r.hasSignature)) {
|
|
596
|
+
this.authState.mintingFee = await this.feeAuthConfig.getMintingFee(
|
|
597
|
+
this.ctx,
|
|
598
|
+
this.chainId
|
|
599
|
+
), this.updateStatus(a.NEEDS_FEE_AUTHORIZATION), this.emitInitialProgress();
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
r.signature && (this.authState.signature = r.signature, this.authState.typedData = r.typedData), this.authState.authorized = !0;
|
|
603
|
+
}
|
|
604
|
+
this.updateStatus(a.ADDRESS_READY), this.emitInitialProgress();
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
if (this.feeAuthConfig) {
|
|
608
|
+
const r = await this.feeAuthConfig.restoreFeeSignature(
|
|
609
|
+
this.ctx,
|
|
610
|
+
this.chainId,
|
|
611
|
+
t.recipient
|
|
612
|
+
);
|
|
613
|
+
if (r != null && r.hasSignature) {
|
|
614
|
+
r.signature && (this.authState.signature = r.signature, this.authState.typedData = r.typedData), this.authState.authorized = !0, this.updateStatus(a.READY), this.emitInitialProgress();
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
this.authState.mintingFee = await this.feeAuthConfig.getMintingFee(
|
|
618
|
+
this.ctx,
|
|
619
|
+
this.chainId
|
|
620
|
+
), this.updateStatus(a.NEEDS_FEE_AUTHORIZATION);
|
|
621
|
+
} else
|
|
622
|
+
this.updateStatus(a.NEEDS_ADDRESS_CONFIRMATION);
|
|
623
|
+
this.emitInitialProgress();
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
async authorizeFee() {
|
|
627
|
+
if (this.assertStatus(
|
|
628
|
+
[a.NEEDS_FEE_AUTHORIZATION, a.READY],
|
|
629
|
+
"authorizeFee"
|
|
630
|
+
), this.status === a.READY) return;
|
|
631
|
+
if (!this.feeAuthConfig)
|
|
632
|
+
throw new u(
|
|
633
|
+
c.INVALID_PARAMETER,
|
|
634
|
+
"Fee authorization is not required for this destination chain. Use confirmAddress() instead."
|
|
635
|
+
);
|
|
636
|
+
const s = this.ensureRecipient();
|
|
637
|
+
if (!this.authState.mintingFee)
|
|
638
|
+
throw new u(
|
|
639
|
+
c.INVALID_STATE,
|
|
640
|
+
"Minting fee not available. Call prepare() first."
|
|
641
|
+
);
|
|
642
|
+
return this.act(async () => {
|
|
643
|
+
const t = await this.feeAuthConfig.authorizeFee(this.ctx, {
|
|
644
|
+
chainId: this.chainId,
|
|
645
|
+
recipient: s,
|
|
646
|
+
fee: this.authState.mintingFee
|
|
647
|
+
});
|
|
648
|
+
this.authState.signature = t.signature, this.authState.typedData = t.typedData, this.authState.authorized = !0;
|
|
649
|
+
}, a.READY);
|
|
650
|
+
}
|
|
651
|
+
async confirmAddress() {
|
|
652
|
+
if (this.assertStatus(
|
|
653
|
+
[a.NEEDS_ADDRESS_CONFIRMATION, a.READY],
|
|
654
|
+
"confirmAddress"
|
|
655
|
+
), this.status === a.READY) return;
|
|
656
|
+
if (this.feeAuthConfig)
|
|
657
|
+
throw new u(
|
|
658
|
+
c.INVALID_PARAMETER,
|
|
659
|
+
"This destination chain requires fee authorization. Use authorizeFee() instead."
|
|
660
|
+
);
|
|
661
|
+
const s = this.ensureRecipient();
|
|
662
|
+
return this.act(async () => {
|
|
663
|
+
const t = await C.signDestination(
|
|
664
|
+
this.ctx,
|
|
665
|
+
s,
|
|
666
|
+
this.chainId
|
|
667
|
+
);
|
|
668
|
+
this.authState.signature = t.signature, this.authState.typedData = t.typedData, this.authState.authorized = !0;
|
|
669
|
+
}, a.READY);
|
|
670
|
+
}
|
|
671
|
+
async execute() {
|
|
672
|
+
return this.executeImpl();
|
|
673
|
+
}
|
|
674
|
+
async monitorDeposit() {
|
|
675
|
+
return super.monitorDeposit();
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
const vt = dt.map(
|
|
679
|
+
(e) => tt(e)
|
|
680
|
+
), Rt = {
|
|
681
|
+
chainType: "evm",
|
|
682
|
+
routes: [
|
|
683
|
+
{
|
|
684
|
+
sourceChains: [g.BITCOIN_MAINNET],
|
|
685
|
+
envs: [h.prod]
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
sourceChains: [g.BITCOIN_SIGNET],
|
|
689
|
+
envs: [h.stage, h.dev, h.testnet, h.ibc]
|
|
690
|
+
}
|
|
691
|
+
],
|
|
692
|
+
// StakeAndDeploy requires vault support - uses VEDA_VAULT_STAKE_AND_BAKE_CHAINS as source of truth
|
|
693
|
+
destChains: vt,
|
|
694
|
+
// StakeAndDeploy produces LBTC (then deposits to vault)
|
|
695
|
+
supportedAssetsOut: [f.LBTC],
|
|
696
|
+
supportedProtocols: Mt(f.LBTC),
|
|
697
|
+
addressSchema: N,
|
|
698
|
+
async getStakeAndBakeFee(e, i, s) {
|
|
699
|
+
return e.capabilities.require("evm").getStakeAndBakeFee(i, s);
|
|
700
|
+
},
|
|
701
|
+
async authorizeStakeAndBake(e, { chainId: i, recipient: s, amount: t, vaultKey: n, token: r }) {
|
|
702
|
+
const d = e.capabilities.require("evm"), A = await e.getProvider("evm");
|
|
703
|
+
if (!A)
|
|
704
|
+
throw u.providerMissing(String(i), "evm");
|
|
705
|
+
await m(A, i);
|
|
706
|
+
const p = await d.signStakeAndBake({
|
|
707
|
+
value: t,
|
|
708
|
+
account: s,
|
|
709
|
+
chainId: i,
|
|
710
|
+
provider: A,
|
|
711
|
+
vaultKey: n,
|
|
712
|
+
token: r
|
|
713
|
+
});
|
|
714
|
+
return await e.api.storeStakeAndBakeSignature({
|
|
715
|
+
signature: p.signature,
|
|
716
|
+
typedData: p.typedData
|
|
717
|
+
}), {
|
|
718
|
+
signature: p.signature,
|
|
719
|
+
typedData: p.typedData
|
|
720
|
+
};
|
|
721
|
+
},
|
|
722
|
+
async restoreStakeAndBakeSignature(e, i, s) {
|
|
723
|
+
try {
|
|
724
|
+
const t = await ut({
|
|
725
|
+
userDestinationAddress: s,
|
|
726
|
+
chainId: i,
|
|
727
|
+
env: e.env
|
|
728
|
+
});
|
|
729
|
+
return !(t.signature || t.expirationDate) || t.expirationDate && Number(t.expirationDate) * 1e3 < Date.now() ? null : {
|
|
730
|
+
hasSignature: !0,
|
|
731
|
+
signature: t.signature,
|
|
732
|
+
depositAmount: t.depositAmount,
|
|
733
|
+
expirationDate: t.expirationDate
|
|
734
|
+
};
|
|
735
|
+
} catch {
|
|
736
|
+
return null;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}, l = Rt;
|
|
740
|
+
function Ot(e) {
|
|
741
|
+
return l.destChains.includes(e);
|
|
742
|
+
}
|
|
743
|
+
function Pt(e) {
|
|
744
|
+
return l.supportedAssetsOut.includes(e);
|
|
745
|
+
}
|
|
746
|
+
function Lt(e, i) {
|
|
747
|
+
return e ? l.routes.some(
|
|
748
|
+
(s) => s.sourceChains.includes(e) && s.envs.includes(i)
|
|
749
|
+
) : !0;
|
|
750
|
+
}
|
|
751
|
+
function Y(e) {
|
|
752
|
+
return e in I;
|
|
753
|
+
}
|
|
754
|
+
function kt(e) {
|
|
755
|
+
if (!Y(e)) {
|
|
756
|
+
const i = Object.keys(I).join(", ");
|
|
757
|
+
throw new Error(
|
|
758
|
+
`Unsupported protocol: ${e}. Supported protocols: ${i}`
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
return e;
|
|
762
|
+
}
|
|
763
|
+
function bt(e) {
|
|
764
|
+
return Object.entries(I).filter(([i, s]) => e in s).map(([i]) => i);
|
|
765
|
+
}
|
|
766
|
+
const z = {
|
|
767
|
+
mainnet: [g.AVALANCHE],
|
|
768
|
+
testnet: [g.AVALANCHE_FUJI]
|
|
769
|
+
}, Bt = {
|
|
770
|
+
chainType: "evm",
|
|
771
|
+
routes: [
|
|
772
|
+
{
|
|
773
|
+
sourceChains: [g.BITCOIN_MAINNET],
|
|
774
|
+
envs: [h.prod]
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
sourceChains: [g.BITCOIN_SIGNET],
|
|
778
|
+
envs: [h.stage, h.dev, h.testnet, h.ibc]
|
|
779
|
+
}
|
|
780
|
+
],
|
|
781
|
+
// DepositAndDeploy with BTC.b is available on Avalanche
|
|
782
|
+
destChains: [
|
|
783
|
+
...z.mainnet,
|
|
784
|
+
...z.testnet
|
|
785
|
+
],
|
|
786
|
+
// DepositAndDeploy produces BTC.b (then deposits to vault)
|
|
787
|
+
supportedAssetsOut: [f.BTCb],
|
|
788
|
+
supportedProtocols: bt(f.BTCb),
|
|
789
|
+
addressSchema: N,
|
|
790
|
+
async getDepositAndDeployFee(e, i, s) {
|
|
791
|
+
return e.capabilities.require("evm").getStakeAndBakeFee(i, s);
|
|
792
|
+
},
|
|
793
|
+
async authorizeDepositAndDeploy(e, { chainId: i, recipient: s, amount: t, vaultKey: n, token: r }) {
|
|
794
|
+
const d = e.capabilities.require("evm"), A = await e.getProvider("evm");
|
|
795
|
+
if (!A)
|
|
796
|
+
throw u.providerMissing(String(i), "evm");
|
|
797
|
+
await m(A, i);
|
|
798
|
+
const p = await d.signStakeAndBake({
|
|
799
|
+
value: t,
|
|
800
|
+
account: s,
|
|
801
|
+
chainId: i,
|
|
802
|
+
provider: A,
|
|
803
|
+
vaultKey: n,
|
|
804
|
+
token: r
|
|
805
|
+
});
|
|
806
|
+
return await e.api.storeStakeAndBakeSignature({
|
|
807
|
+
signature: p.signature,
|
|
808
|
+
typedData: p.typedData
|
|
809
|
+
}), {
|
|
810
|
+
signature: p.signature,
|
|
811
|
+
typedData: p.typedData,
|
|
812
|
+
// approvalTxHash may not be present in the result for all flows
|
|
813
|
+
approvalTxHash: p.approvalTxHash
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
}, E = Bt;
|
|
817
|
+
function Ft(e) {
|
|
818
|
+
return E.destChains.includes(e);
|
|
819
|
+
}
|
|
820
|
+
function xt(e) {
|
|
821
|
+
return E.supportedAssetsOut.includes(e);
|
|
822
|
+
}
|
|
823
|
+
function $(e) {
|
|
824
|
+
return e in I;
|
|
825
|
+
}
|
|
826
|
+
function H(e) {
|
|
827
|
+
if (!$(e)) {
|
|
828
|
+
const i = Object.keys(I).join(", ");
|
|
829
|
+
throw new Error(
|
|
830
|
+
`Unsupported protocol: ${e}. Supported protocols: ${i}`
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
return e;
|
|
834
|
+
}
|
|
835
|
+
function Mt(e) {
|
|
836
|
+
return Object.entries(I).filter(([i, s]) => e in s).map(([i]) => i);
|
|
837
|
+
}
|
|
838
|
+
function zt(e, i) {
|
|
839
|
+
return E.routes.some(
|
|
840
|
+
(s) => s.sourceChains.includes(e) && s.envs.includes(i)
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
class Ht extends P {
|
|
844
|
+
constructor(s, t) {
|
|
845
|
+
super(s, t, a.IDLE);
|
|
846
|
+
D(this, "chainId");
|
|
847
|
+
D(this, "authState", { authorized: !1 });
|
|
848
|
+
if (!xt(t.assetOut))
|
|
849
|
+
throw new u(
|
|
850
|
+
c.INVALID_ASSET,
|
|
851
|
+
`Asset ${t.assetOut} is not supported for deposit and deploy. DepositAndDeploy produces BTC.b which is then deployed to a vault like Silo.`
|
|
852
|
+
);
|
|
853
|
+
if (!Ft(t.destChain))
|
|
854
|
+
throw new u(
|
|
855
|
+
c.INVALID_CHAIN,
|
|
856
|
+
`Destination chain ${t.destChain} is not supported for deposit and deploy. Supported chains: Avalanche, Avalanche Fuji`
|
|
857
|
+
);
|
|
858
|
+
if (!$(t.protocol))
|
|
859
|
+
throw new u(
|
|
860
|
+
c.INVALID_PARAMETER,
|
|
861
|
+
`Protocol ${t.protocol} is not supported for deposit and deploy. DepositAndDeploy with BTC.b only supports Silo protocol.`
|
|
862
|
+
);
|
|
863
|
+
const n = t.sourceChain ?? g.BITCOIN_MAINNET;
|
|
864
|
+
if (!zt(n, s.env))
|
|
865
|
+
throw u.routeNotFound({
|
|
866
|
+
assetOut: t.assetOut,
|
|
867
|
+
sourceChain: n,
|
|
868
|
+
destChain: t.destChain,
|
|
869
|
+
env: s.env
|
|
870
|
+
});
|
|
871
|
+
const r = v(t.destChain);
|
|
872
|
+
if (typeof r != "number" || !b(r))
|
|
873
|
+
throw new u(
|
|
874
|
+
c.INVALID_CHAIN,
|
|
875
|
+
`Unsupported EVM chain: ${t.destChain}`
|
|
876
|
+
);
|
|
877
|
+
this.chainId = r;
|
|
878
|
+
}
|
|
879
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
880
|
+
// Abstract Method Implementations
|
|
881
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
882
|
+
getAddressSchema() {
|
|
883
|
+
return E.addressSchema;
|
|
884
|
+
}
|
|
885
|
+
getStatusConfig() {
|
|
886
|
+
return {
|
|
887
|
+
idle: a.IDLE,
|
|
888
|
+
ready: a.READY,
|
|
889
|
+
addressReady: a.ADDRESS_READY
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
getInitialSteps() {
|
|
893
|
+
return {
|
|
894
|
+
created: o.IDLE,
|
|
895
|
+
verifying: o.IDLE,
|
|
896
|
+
wrapping: o.IDLE,
|
|
897
|
+
depositing: o.IDLE
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
isAuthorized() {
|
|
901
|
+
return this.authState.authorized;
|
|
902
|
+
}
|
|
903
|
+
getChainId() {
|
|
904
|
+
return this.chainId;
|
|
905
|
+
}
|
|
906
|
+
getDepositAddressParams() {
|
|
907
|
+
return {
|
|
908
|
+
address: this.ensureRecipient(),
|
|
909
|
+
chainId: this.chainId,
|
|
910
|
+
signature: this.authState.signature,
|
|
911
|
+
token: this.getExpectedToken(),
|
|
912
|
+
// Deposit and deploy uses signatureData (maps to sb_signature_data), not eip712Data
|
|
913
|
+
signatureData: this.authState.typedData,
|
|
914
|
+
partnerId: this.ctx.partner.getPartnerId(),
|
|
915
|
+
referrerCode: this._referralCode
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Get expected token for this action (BTCb by default for DepositAndDeploy)
|
|
920
|
+
*/
|
|
921
|
+
getExpectedToken() {
|
|
922
|
+
return w(this.params.assetOut, S.BTCb);
|
|
923
|
+
}
|
|
924
|
+
getAuthRequiredMessage() {
|
|
925
|
+
return "Deposit authorization required. Call authorizeDeposit() first.";
|
|
926
|
+
}
|
|
927
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
928
|
+
// Public Getters
|
|
929
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
930
|
+
/** Get deposit and deploy fee (available after prepare()) */
|
|
931
|
+
get fee() {
|
|
932
|
+
return this.authState.fee;
|
|
933
|
+
}
|
|
934
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
935
|
+
// Public Methods
|
|
936
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
937
|
+
async prepare(s) {
|
|
938
|
+
return this.assertStatus(a.IDLE, "prepare"), this.act(async () => {
|
|
939
|
+
const t = this.validatePrepareParams(s);
|
|
940
|
+
this._amount = t.amount, this._recipient = t.recipient, this._referralCode = t.referralCode, this.authState.fee = await E.getDepositAndDeployFee(
|
|
941
|
+
this.ctx,
|
|
942
|
+
this.chainId,
|
|
943
|
+
H(this.params.protocol)
|
|
944
|
+
), this.updateStatus(a.NEEDS_DEPLOY_AUTHORIZATION), this.emitInitialProgress();
|
|
945
|
+
}, a.NEEDS_DEPLOY_AUTHORIZATION);
|
|
946
|
+
}
|
|
947
|
+
async authorizeDeposit() {
|
|
948
|
+
if (this.assertStatus(
|
|
949
|
+
[a.NEEDS_DEPLOY_AUTHORIZATION, a.READY],
|
|
950
|
+
"authorizeDeposit"
|
|
951
|
+
), this.status === a.READY) return;
|
|
952
|
+
const s = this.ensureRecipient(), t = this.ensureAmount();
|
|
953
|
+
return this.act(async () => {
|
|
954
|
+
const n = T(t), r = w(this.params.assetOut, S.BTCb), d = await E.authorizeDepositAndDeploy(
|
|
955
|
+
this.ctx,
|
|
956
|
+
{
|
|
957
|
+
chainId: this.chainId,
|
|
958
|
+
recipient: s,
|
|
959
|
+
amount: n.toString(),
|
|
960
|
+
vaultKey: H(this.params.protocol),
|
|
961
|
+
token: r
|
|
962
|
+
}
|
|
963
|
+
);
|
|
964
|
+
this.authState.signature = d.signature, this.authState.typedData = d.typedData, this.authState.authorized = !0;
|
|
965
|
+
}, a.READY);
|
|
966
|
+
}
|
|
967
|
+
async generateDepositAddress() {
|
|
968
|
+
return this.assertStatus(a.READY, "generateDepositAddress"), this.ensureAuthorized(), this._depositAddress ? this._depositAddress : this.act(async () => {
|
|
969
|
+
const s = this.getDepositAddressParams(), t = await this.ctx.api.generateDepositAddress(s);
|
|
970
|
+
return O(t), this._depositAddress = t, this.emitProgress({
|
|
971
|
+
status: a.ADDRESS_READY,
|
|
972
|
+
steps: {
|
|
973
|
+
created: o.COMPLETE,
|
|
974
|
+
verifying: o.IDLE,
|
|
975
|
+
wrapping: o.IDLE,
|
|
976
|
+
depositing: o.IDLE
|
|
977
|
+
},
|
|
978
|
+
metadata: { depositAddress: t }
|
|
979
|
+
}), t;
|
|
980
|
+
}, a.ADDRESS_READY);
|
|
981
|
+
}
|
|
982
|
+
async execute() {
|
|
983
|
+
return this.act(async () => {
|
|
984
|
+
this.assertStatus(a.ADDRESS_READY, "execute"), this._depositAddress || await this.generateDepositAddress();
|
|
985
|
+
const s = this.ensureDepositAddress(), t = await this.trySendBitcoin(s);
|
|
986
|
+
return t ? { depositAddress: s, txHash: t } : { depositAddress: s };
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
// Custom monitorDeposit with different step names
|
|
990
|
+
async monitorDeposit() {
|
|
991
|
+
const s = this._depositAddress, t = this._recipient;
|
|
992
|
+
if (!s || !t)
|
|
993
|
+
throw u.missingParameter("depositAddress or recipient");
|
|
994
|
+
return await B({
|
|
995
|
+
network: this.bitcoinNetwork,
|
|
996
|
+
btcService: this.ctx.btc,
|
|
997
|
+
fetchDeposit: async () => {
|
|
998
|
+
const d = (await this.ctx.api.getDeposits(t)).find(
|
|
999
|
+
(A) => A.depositAddress === s
|
|
1000
|
+
);
|
|
1001
|
+
if (d)
|
|
1002
|
+
return {
|
|
1003
|
+
blockHeight: d.blockHeight,
|
|
1004
|
+
isClaimed: d.isClaimed
|
|
1005
|
+
};
|
|
1006
|
+
},
|
|
1007
|
+
onProgress: (r) => {
|
|
1008
|
+
this.emitProgress({
|
|
1009
|
+
status: this.status,
|
|
1010
|
+
steps: {
|
|
1011
|
+
created: o.COMPLETE,
|
|
1012
|
+
verifying: r.hasEnoughConfirmations ? o.COMPLETE : o.PENDING,
|
|
1013
|
+
wrapping: r.isClaimed ? o.COMPLETE : o.PENDING,
|
|
1014
|
+
depositing: o.PENDING
|
|
1015
|
+
},
|
|
1016
|
+
confirmations: r.confirmations,
|
|
1017
|
+
requiredConfirmations: r.requiredConfirmations,
|
|
1018
|
+
metadata: { isClaimed: r.isClaimed }
|
|
1019
|
+
});
|
|
1020
|
+
},
|
|
1021
|
+
onComplete: () => {
|
|
1022
|
+
this.emitCompleted();
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
const L = (e) => `${e}${et}`;
|
|
1028
|
+
function Yt(e) {
|
|
1029
|
+
return String(e).startsWith(L(R.EIP155));
|
|
1030
|
+
}
|
|
1031
|
+
function $t(e) {
|
|
1032
|
+
return String(e).startsWith(L(R.SOLANA));
|
|
1033
|
+
}
|
|
1034
|
+
function qt(e) {
|
|
1035
|
+
return String(e).startsWith(L(R.SUI));
|
|
1036
|
+
}
|
|
1037
|
+
function Vt(e) {
|
|
1038
|
+
return String(e).startsWith(L(R.STARKNET));
|
|
1039
|
+
}
|
|
1040
|
+
const Ut = [g.ETHEREUM, g.SEPOLIA], Gt = {
|
|
1041
|
+
async getMintingFee(e, i) {
|
|
1042
|
+
return e.capabilities.require("evm").getMintingFee(i);
|
|
1043
|
+
},
|
|
1044
|
+
async restoreFeeSignature(e, i, s) {
|
|
1045
|
+
const t = await _(
|
|
1046
|
+
S.LBTC,
|
|
1047
|
+
i,
|
|
1048
|
+
e.env
|
|
1049
|
+
), n = await e.api.getFeeSignature({
|
|
1050
|
+
address: s,
|
|
1051
|
+
chainId: i,
|
|
1052
|
+
tokenAddress: t.address
|
|
1053
|
+
});
|
|
1054
|
+
return !n.hasSignature || n.expirationDate && new Date(Number(n.expirationDate) * 1e3) < /* @__PURE__ */ new Date() ? null : {
|
|
1055
|
+
hasSignature: !0,
|
|
1056
|
+
signature: n.signature,
|
|
1057
|
+
// May be undefined - that's OK
|
|
1058
|
+
typedData: n.typedData
|
|
1059
|
+
};
|
|
1060
|
+
},
|
|
1061
|
+
async authorizeFee(e, { chainId: i, recipient: s, fee: t }) {
|
|
1062
|
+
const n = e.capabilities.require("evm"), r = await e.getProvider("evm");
|
|
1063
|
+
if (!r)
|
|
1064
|
+
throw u.providerMissing(String(i), "evm");
|
|
1065
|
+
await m(r, i);
|
|
1066
|
+
const d = T(t).toString(), A = await _(
|
|
1067
|
+
S.LBTC,
|
|
1068
|
+
i,
|
|
1069
|
+
e.env
|
|
1070
|
+
), p = await n.signNetworkFee({
|
|
1071
|
+
fee: d,
|
|
1072
|
+
account: s,
|
|
1073
|
+
chainId: i,
|
|
1074
|
+
provider: r,
|
|
1075
|
+
token: S.LBTC
|
|
1076
|
+
});
|
|
1077
|
+
return await e.api.storeFeeSignature({
|
|
1078
|
+
address: s,
|
|
1079
|
+
signature: p.signature,
|
|
1080
|
+
typedData: p.typedData,
|
|
1081
|
+
tokenAddress: A.address
|
|
1082
|
+
}), {
|
|
1083
|
+
signature: p.signature,
|
|
1084
|
+
typedData: p.typedData
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
}, Kt = {
|
|
1088
|
+
chainType: "evm",
|
|
1089
|
+
routes: [
|
|
1090
|
+
{
|
|
1091
|
+
sourceChains: [g.BITCOIN_MAINNET],
|
|
1092
|
+
envs: [h.prod]
|
|
1093
|
+
},
|
|
1094
|
+
{
|
|
1095
|
+
sourceChains: [g.BITCOIN_SIGNET],
|
|
1096
|
+
envs: [h.testnet, h.stage, h.dev, h.ibc]
|
|
1097
|
+
}
|
|
1098
|
+
],
|
|
1099
|
+
// Derived from ASSET_CATALOG - all EVM chains where LBTC is deployed
|
|
1100
|
+
// Note: This includes all chains across all environments
|
|
1101
|
+
// The `routes` config above filters by source chain + env
|
|
1102
|
+
destChains: y(f.LBTC).filter((e) => Yt(e)),
|
|
1103
|
+
// BTC Stake only produces LBTC
|
|
1104
|
+
supportedAssetsOut: [f.LBTC],
|
|
1105
|
+
addressSchema: N,
|
|
1106
|
+
getFeeAuthConfig(e) {
|
|
1107
|
+
return Ut.includes(e) ? Gt : null;
|
|
1108
|
+
},
|
|
1109
|
+
async getSignature(e, i, s) {
|
|
1110
|
+
const t = e.capabilities.require("evm"), n = await e.getProvider("evm");
|
|
1111
|
+
if (!n)
|
|
1112
|
+
throw u.providerMissing(String(s), "evm");
|
|
1113
|
+
return await m(n, s), t.signLbtcDestination({
|
|
1114
|
+
chainId: s,
|
|
1115
|
+
address: i,
|
|
1116
|
+
provider: n
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
function jt(e) {
|
|
1121
|
+
const i = {
|
|
1122
|
+
// CAIP-2 format using genesis hash
|
|
1123
|
+
[g.SOLANA_MAINNET]: "mainnet-beta",
|
|
1124
|
+
[g.SOLANA_DEVNET]: "devnet",
|
|
1125
|
+
[g.SOLANA_TESTNET]: "testnet",
|
|
1126
|
+
// Legacy format (solana:network-name)
|
|
1127
|
+
"solana:mainnet-beta": "mainnet-beta",
|
|
1128
|
+
"solana:devnet": "devnet",
|
|
1129
|
+
"solana:testnet": "testnet"
|
|
1130
|
+
}, s = i[e];
|
|
1131
|
+
if (!s)
|
|
1132
|
+
throw new u(
|
|
1133
|
+
c.INVALID_CHAIN,
|
|
1134
|
+
`Unknown Solana chain: ${e}. Expected one of: ${Object.keys(i).join(", ")}`
|
|
1135
|
+
);
|
|
1136
|
+
return s;
|
|
1137
|
+
}
|
|
1138
|
+
const Zt = {
|
|
1139
|
+
chainType: "solana",
|
|
1140
|
+
routes: [
|
|
1141
|
+
{
|
|
1142
|
+
sourceChains: [g.BITCOIN_MAINNET],
|
|
1143
|
+
envs: [h.prod]
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
sourceChains: [g.BITCOIN_SIGNET],
|
|
1147
|
+
envs: [h.testnet, h.stage, h.dev, h.ibc]
|
|
1148
|
+
}
|
|
1149
|
+
],
|
|
1150
|
+
// Derived from ASSET_CATALOG - Solana chains where LBTC is deployed
|
|
1151
|
+
destChains: y(f.LBTC).filter(
|
|
1152
|
+
(e) => $t(e)
|
|
1153
|
+
),
|
|
1154
|
+
// BTC Stake only produces LBTC
|
|
1155
|
+
supportedAssetsOut: [f.LBTC],
|
|
1156
|
+
addressSchema: st,
|
|
1157
|
+
// Solana never requires fee authorization
|
|
1158
|
+
getFeeAuthConfig: () => null,
|
|
1159
|
+
async getSignature(e, i, s) {
|
|
1160
|
+
const t = e.capabilities.require("solana"), n = jt(s), { signature: r } = await t.signLbtcDestination({
|
|
1161
|
+
network: n
|
|
1162
|
+
});
|
|
1163
|
+
return { signature: r };
|
|
1164
|
+
}
|
|
1165
|
+
}, Wt = {
|
|
1166
|
+
chainType: "starknet",
|
|
1167
|
+
routes: [
|
|
1168
|
+
{
|
|
1169
|
+
sourceChains: [g.BITCOIN_MAINNET],
|
|
1170
|
+
envs: [h.prod]
|
|
1171
|
+
},
|
|
1172
|
+
{
|
|
1173
|
+
sourceChains: [g.BITCOIN_SIGNET],
|
|
1174
|
+
envs: [h.testnet, h.stage, h.dev, h.ibc]
|
|
1175
|
+
}
|
|
1176
|
+
],
|
|
1177
|
+
// Derived from ASSET_CATALOG - Starknet chains where LBTC is deployed
|
|
1178
|
+
destChains: y(f.LBTC).filter(
|
|
1179
|
+
(e) => Vt(e)
|
|
1180
|
+
),
|
|
1181
|
+
// BTC Stake only produces LBTC
|
|
1182
|
+
supportedAssetsOut: [f.LBTC],
|
|
1183
|
+
addressSchema: it,
|
|
1184
|
+
// Starknet never requires fee authorization
|
|
1185
|
+
getFeeAuthConfig: () => null,
|
|
1186
|
+
async getSignature(e, i, s) {
|
|
1187
|
+
const t = e.capabilities.require("starknet"), { signature: n, pubKey: r } = await t.signLbtcDestination({
|
|
1188
|
+
chainId: s
|
|
1189
|
+
}), d = ht(i, { size: 32 });
|
|
1190
|
+
return { signature: n, pubKey: r, paddedAddress: d };
|
|
1191
|
+
}
|
|
1192
|
+
}, Xt = {
|
|
1193
|
+
chainType: "sui",
|
|
1194
|
+
routes: [
|
|
1195
|
+
{
|
|
1196
|
+
sourceChains: [g.BITCOIN_MAINNET],
|
|
1197
|
+
envs: [h.prod]
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
sourceChains: [g.BITCOIN_SIGNET],
|
|
1201
|
+
envs: [h.testnet, h.stage, h.dev, h.ibc]
|
|
1202
|
+
}
|
|
1203
|
+
],
|
|
1204
|
+
// Derived from ASSET_CATALOG - Sui chains where LBTC is deployed
|
|
1205
|
+
destChains: y(f.LBTC).filter(
|
|
1206
|
+
(e) => qt(e)
|
|
1207
|
+
),
|
|
1208
|
+
// BTC Stake only produces LBTC
|
|
1209
|
+
supportedAssetsOut: [f.LBTC],
|
|
1210
|
+
addressSchema: rt,
|
|
1211
|
+
// Sui never requires fee authorization
|
|
1212
|
+
getFeeAuthConfig: () => null,
|
|
1213
|
+
async getSignature(e, i, s) {
|
|
1214
|
+
const t = e.capabilities.require("sui"), { signature: n } = await t.signLbtcDestination({
|
|
1215
|
+
chainId: s
|
|
1216
|
+
});
|
|
1217
|
+
return { signature: n };
|
|
1218
|
+
}
|
|
1219
|
+
}, Jt = {
|
|
1220
|
+
evm: Kt,
|
|
1221
|
+
solana: Zt,
|
|
1222
|
+
sui: Xt,
|
|
1223
|
+
starknet: Wt
|
|
1224
|
+
};
|
|
1225
|
+
function Qt(e) {
|
|
1226
|
+
return Jt[e];
|
|
1227
|
+
}
|
|
1228
|
+
function te(e, i, s) {
|
|
1229
|
+
return i ? e.routes.some(
|
|
1230
|
+
(t) => t.sourceChains.includes(i) && t.envs.includes(s)
|
|
1231
|
+
) : !0;
|
|
1232
|
+
}
|
|
1233
|
+
function ee(e, i) {
|
|
1234
|
+
return e.destChains.includes(i);
|
|
1235
|
+
}
|
|
1236
|
+
function se(e, i) {
|
|
1237
|
+
return e.supportedAssetsOut.includes(i);
|
|
1238
|
+
}
|
|
1239
|
+
class ie extends P {
|
|
1240
|
+
constructor(s, t) {
|
|
1241
|
+
super(s, t, a.IDLE);
|
|
1242
|
+
D(this, "config");
|
|
1243
|
+
D(this, "chainId");
|
|
1244
|
+
D(this, "authState", { authorized: !1 });
|
|
1245
|
+
/** Fee auth config - null if not required for this destination */
|
|
1246
|
+
D(this, "feeAuthConfig", null);
|
|
1247
|
+
const n = nt(t.destChain), r = Qt(n);
|
|
1248
|
+
if (!r)
|
|
1249
|
+
throw new u(
|
|
1250
|
+
c.INVALID_CHAIN,
|
|
1251
|
+
`Unsupported destination chain type: ${n} (${t.destChain})`
|
|
1252
|
+
);
|
|
1253
|
+
if (!se(r, t.assetOut))
|
|
1254
|
+
throw new u(
|
|
1255
|
+
c.INVALID_ASSET,
|
|
1256
|
+
`Asset ${t.assetOut} is not supported for BTC staking. BTC Stake produces LBTC. For BTC.b, use BtcDeposit instead.`
|
|
1257
|
+
);
|
|
1258
|
+
if (!ee(r, t.destChain))
|
|
1259
|
+
throw new u(
|
|
1260
|
+
c.INVALID_CHAIN,
|
|
1261
|
+
`Destination chain ${t.destChain} is not supported for ${n}`
|
|
1262
|
+
);
|
|
1263
|
+
if (!te(r, t.sourceChain, s.env))
|
|
1264
|
+
throw u.routeNotFound({
|
|
1265
|
+
assetOut: t.assetOut,
|
|
1266
|
+
sourceChain: t.sourceChain,
|
|
1267
|
+
destChain: t.destChain,
|
|
1268
|
+
env: s.env
|
|
1269
|
+
});
|
|
1270
|
+
this.config = r, this.chainId = v(t.destChain);
|
|
1271
|
+
}
|
|
1272
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1273
|
+
// Abstract Method Implementations
|
|
1274
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1275
|
+
getAddressSchema() {
|
|
1276
|
+
return this.config.addressSchema;
|
|
1277
|
+
}
|
|
1278
|
+
getStatusConfig() {
|
|
1279
|
+
return {
|
|
1280
|
+
idle: a.IDLE,
|
|
1281
|
+
ready: a.READY,
|
|
1282
|
+
addressReady: a.ADDRESS_READY
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
getInitialSteps() {
|
|
1286
|
+
return {
|
|
1287
|
+
created: o.IDLE,
|
|
1288
|
+
verifying: o.IDLE,
|
|
1289
|
+
issuing: o.IDLE
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
isAuthorized() {
|
|
1293
|
+
return this.authState.authorized;
|
|
1294
|
+
}
|
|
1295
|
+
getChainId() {
|
|
1296
|
+
return this.chainId;
|
|
1297
|
+
}
|
|
1298
|
+
getDepositAddressParams() {
|
|
1299
|
+
var n;
|
|
1300
|
+
const s = this.ensureRecipient(), t = this.getActiveSignature();
|
|
1301
|
+
if (!t)
|
|
1302
|
+
throw new u(
|
|
1303
|
+
c.INVALID_PARAMETER,
|
|
1304
|
+
"Missing signature. Complete authorization first."
|
|
1305
|
+
);
|
|
1306
|
+
return {
|
|
1307
|
+
address: t.paddedAddress ?? s,
|
|
1308
|
+
chainId: this.chainId,
|
|
1309
|
+
signature: t.signature,
|
|
1310
|
+
token: this.getExpectedToken(),
|
|
1311
|
+
eip712Data: (n = this.authState.networkFee) == null ? void 0 : n.typedData,
|
|
1312
|
+
pubKey: t.pubKey,
|
|
1313
|
+
partnerId: this.ctx.partner.getPartnerId(),
|
|
1314
|
+
referrerCode: this._referralCode
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Get expected token for this action (LBTC by default for BTC Stake)
|
|
1319
|
+
*/
|
|
1320
|
+
getExpectedToken() {
|
|
1321
|
+
return w(this.params.assetOut, S.LBTC);
|
|
1322
|
+
}
|
|
1323
|
+
getAuthRequiredMessage() {
|
|
1324
|
+
return "Authorization required. Call authorize() first.";
|
|
1325
|
+
}
|
|
1326
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1327
|
+
// Public Getters
|
|
1328
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1329
|
+
/** Get minting fee (available after prepare() for fee-auth chains) */
|
|
1330
|
+
get mintingFee() {
|
|
1331
|
+
return this.authState.mintingFee;
|
|
1332
|
+
}
|
|
1333
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1334
|
+
// Public Methods
|
|
1335
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1336
|
+
async prepare(s) {
|
|
1337
|
+
return this.assertStatus(a.IDLE, "prepare"), this.act(async () => {
|
|
1338
|
+
const t = this.validatePrepareParams(s);
|
|
1339
|
+
if (this._amount = t.amount, this._recipient = t.recipient, this._referralCode = t.referralCode, this.feeAuthConfig = this.config.getFeeAuthConfig(this.params.destChain), await this.resumeFromExistingDeposit(
|
|
1340
|
+
t.recipient
|
|
1341
|
+
)) {
|
|
1342
|
+
if (this.feeAuthConfig) {
|
|
1343
|
+
const r = await this.feeAuthConfig.restoreFeeSignature(
|
|
1344
|
+
this.ctx,
|
|
1345
|
+
this.chainId,
|
|
1346
|
+
t.recipient
|
|
1347
|
+
);
|
|
1348
|
+
if (!(r != null && r.hasSignature)) {
|
|
1349
|
+
this.authState.mintingFee = await this.feeAuthConfig.getMintingFee(
|
|
1350
|
+
this.ctx,
|
|
1351
|
+
this.chainId
|
|
1352
|
+
), this.updateStatus(a.NEEDS_FEE_AUTHORIZATION), this.emitInitialProgress();
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
r.signature && (this.authState.networkFee = {
|
|
1356
|
+
signature: r.signature,
|
|
1357
|
+
typedData: r.typedData
|
|
1358
|
+
}), this.authState.authorized = !0;
|
|
1359
|
+
}
|
|
1360
|
+
this.updateStatus(a.ADDRESS_READY), this.emitInitialProgress();
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
if (this.feeAuthConfig) {
|
|
1364
|
+
const r = await this.feeAuthConfig.restoreFeeSignature(
|
|
1365
|
+
this.ctx,
|
|
1366
|
+
this.chainId,
|
|
1367
|
+
t.recipient
|
|
1368
|
+
);
|
|
1369
|
+
if (r != null && r.hasSignature) {
|
|
1370
|
+
r.signature && (this.authState.networkFee = {
|
|
1371
|
+
signature: r.signature,
|
|
1372
|
+
typedData: r.typedData
|
|
1373
|
+
}), this.authState.authorized = !0, this.updateStatus(a.READY), this.emitInitialProgress();
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
this.authState.mintingFee = await this.feeAuthConfig.getMintingFee(
|
|
1377
|
+
this.ctx,
|
|
1378
|
+
this.chainId
|
|
1379
|
+
), this.updateStatus(a.NEEDS_FEE_AUTHORIZATION);
|
|
1380
|
+
} else
|
|
1381
|
+
this.updateStatus(a.NEEDS_ADDRESS_CONFIRMATION);
|
|
1382
|
+
this.emitInitialProgress();
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
async authorize() {
|
|
1386
|
+
if (this.assertStatus(
|
|
1387
|
+
[
|
|
1388
|
+
a.NEEDS_FEE_AUTHORIZATION,
|
|
1389
|
+
a.NEEDS_ADDRESS_CONFIRMATION,
|
|
1390
|
+
a.READY
|
|
1391
|
+
],
|
|
1392
|
+
"authorize"
|
|
1393
|
+
), this.status === a.READY) return;
|
|
1394
|
+
const s = this.ensureRecipient(), t = this.feeAuthConfig !== null;
|
|
1395
|
+
return this.act(async () => {
|
|
1396
|
+
if (t) {
|
|
1397
|
+
const n = this.ensureMintingFee(), r = await this.feeAuthConfig.authorizeFee(this.ctx, {
|
|
1398
|
+
chainId: this.chainId,
|
|
1399
|
+
recipient: s,
|
|
1400
|
+
fee: n
|
|
1401
|
+
});
|
|
1402
|
+
this.authState.networkFee = {
|
|
1403
|
+
signature: r.signature,
|
|
1404
|
+
typedData: r.typedData
|
|
1405
|
+
};
|
|
1406
|
+
} else
|
|
1407
|
+
this.authState.destinationSignature = await this.config.getSignature(
|
|
1408
|
+
this.ctx,
|
|
1409
|
+
s,
|
|
1410
|
+
this.chainId
|
|
1411
|
+
);
|
|
1412
|
+
this.authState.authorized = !0;
|
|
1413
|
+
}, a.READY);
|
|
1414
|
+
}
|
|
1415
|
+
async generateDepositAddress() {
|
|
1416
|
+
if (this.assertStatus(a.READY, "generateDepositAddress"), this.ensureAuthorized(), this._depositAddress)
|
|
1417
|
+
return this._depositAddress;
|
|
1418
|
+
if (!this.getActiveSignature()) {
|
|
1419
|
+
const s = await this.config.getSignature(
|
|
1420
|
+
this.ctx,
|
|
1421
|
+
this.ensureRecipient(),
|
|
1422
|
+
this.chainId
|
|
1423
|
+
);
|
|
1424
|
+
this.authState.destinationSignature = s;
|
|
1425
|
+
}
|
|
1426
|
+
return this.act(async () => {
|
|
1427
|
+
const s = this.getDepositAddressParams(), t = await this.ctx.api.generateDepositAddress(s);
|
|
1428
|
+
return O(t), this._depositAddress = t, this.emitProgress({
|
|
1429
|
+
status: a.ADDRESS_READY,
|
|
1430
|
+
steps: {
|
|
1431
|
+
created: o.COMPLETE,
|
|
1432
|
+
verifying: o.IDLE,
|
|
1433
|
+
issuing: o.IDLE
|
|
1434
|
+
},
|
|
1435
|
+
metadata: { depositAddress: t }
|
|
1436
|
+
}), t;
|
|
1437
|
+
}, a.ADDRESS_READY);
|
|
1438
|
+
}
|
|
1439
|
+
async execute() {
|
|
1440
|
+
return this.executeImpl();
|
|
1441
|
+
}
|
|
1442
|
+
async monitorDeposit() {
|
|
1443
|
+
return super.monitorDeposit();
|
|
1444
|
+
}
|
|
1445
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1446
|
+
// Private: Ensure Methods
|
|
1447
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1448
|
+
ensureMintingFee() {
|
|
1449
|
+
if (!this.authState.mintingFee)
|
|
1450
|
+
throw new u(
|
|
1451
|
+
c.INVALID_PARAMETER,
|
|
1452
|
+
"Minting fee not fetched. Call prepare() first."
|
|
1453
|
+
);
|
|
1454
|
+
return this.authState.mintingFee;
|
|
1455
|
+
}
|
|
1456
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1457
|
+
// Private: Signature Helpers
|
|
1458
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1459
|
+
getActiveSignature() {
|
|
1460
|
+
var s;
|
|
1461
|
+
return (s = this.authState.networkFee) != null && s.signature ? { signature: this.authState.networkFee.signature } : this.authState.destinationSignature;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
class re extends P {
|
|
1465
|
+
constructor(s, t) {
|
|
1466
|
+
super(s, t, a.IDLE);
|
|
1467
|
+
D(this, "chainId");
|
|
1468
|
+
D(this, "authState", { authorized: !1 });
|
|
1469
|
+
if (!Pt(t.assetOut))
|
|
1470
|
+
throw new u(
|
|
1471
|
+
c.INVALID_ASSET,
|
|
1472
|
+
`Asset ${t.assetOut} is not supported for stake and deploy. StakeAndDeploy produces LBTC which is then deployed to a vault.`
|
|
1473
|
+
);
|
|
1474
|
+
if (!Ot(t.destChain))
|
|
1475
|
+
throw new u(
|
|
1476
|
+
c.INVALID_CHAIN,
|
|
1477
|
+
`Destination chain ${t.destChain} is not supported for stake and deploy`
|
|
1478
|
+
);
|
|
1479
|
+
if (!Y(t.protocol))
|
|
1480
|
+
throw new u(
|
|
1481
|
+
c.INVALID_PARAMETER,
|
|
1482
|
+
`Protocol ${t.protocol} is not supported for stake and deploy`
|
|
1483
|
+
);
|
|
1484
|
+
if (!Lt(t.sourceChain, s.env))
|
|
1485
|
+
throw u.routeNotFound({
|
|
1486
|
+
assetOut: t.assetOut,
|
|
1487
|
+
sourceChain: t.sourceChain,
|
|
1488
|
+
destChain: t.destChain,
|
|
1489
|
+
env: s.env
|
|
1490
|
+
});
|
|
1491
|
+
const n = v(t.destChain);
|
|
1492
|
+
if (typeof n != "number" || !b(n))
|
|
1493
|
+
throw new u(
|
|
1494
|
+
c.INVALID_CHAIN,
|
|
1495
|
+
`Unsupported EVM chain: ${t.destChain}`
|
|
1496
|
+
);
|
|
1497
|
+
this.chainId = n;
|
|
1498
|
+
}
|
|
1499
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1500
|
+
// Abstract Method Implementations
|
|
1501
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1502
|
+
getAddressSchema() {
|
|
1503
|
+
return l.addressSchema;
|
|
1504
|
+
}
|
|
1505
|
+
getStatusConfig() {
|
|
1506
|
+
return {
|
|
1507
|
+
idle: a.IDLE,
|
|
1508
|
+
ready: a.READY,
|
|
1509
|
+
addressReady: a.ADDRESS_READY
|
|
1510
|
+
};
|
|
1511
|
+
}
|
|
1512
|
+
getInitialSteps() {
|
|
1513
|
+
return {
|
|
1514
|
+
created: o.IDLE,
|
|
1515
|
+
verifying: o.IDLE,
|
|
1516
|
+
issuing: o.IDLE,
|
|
1517
|
+
depositing: o.IDLE
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
isAuthorized() {
|
|
1521
|
+
return this.authState.authorized;
|
|
1522
|
+
}
|
|
1523
|
+
getChainId() {
|
|
1524
|
+
return this.chainId;
|
|
1525
|
+
}
|
|
1526
|
+
getDepositAddressParams() {
|
|
1527
|
+
return {
|
|
1528
|
+
address: this.ensureRecipient(),
|
|
1529
|
+
chainId: this.chainId,
|
|
1530
|
+
signature: this.authState.signature,
|
|
1531
|
+
token: this.getExpectedToken(),
|
|
1532
|
+
// Stake and bake uses signatureData (maps to sb_signature_data), not eip712Data
|
|
1533
|
+
signatureData: this.authState.typedData,
|
|
1534
|
+
partnerId: this.ctx.partner.getPartnerId(),
|
|
1535
|
+
referrerCode: this._referralCode
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Get expected token for this action (LBTC by default for StakeAndDeploy)
|
|
1540
|
+
*/
|
|
1541
|
+
getExpectedToken() {
|
|
1542
|
+
return w(this.params.assetOut, S.LBTC);
|
|
1543
|
+
}
|
|
1544
|
+
getAuthRequiredMessage() {
|
|
1545
|
+
return "Deposit authorization required. Call authorizeDeposit() first.";
|
|
1546
|
+
}
|
|
1547
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1548
|
+
// Public Getters
|
|
1549
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1550
|
+
/** Get stake and bake fee (available after prepare()) */
|
|
1551
|
+
get fee() {
|
|
1552
|
+
return this.authState.fee;
|
|
1553
|
+
}
|
|
1554
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1555
|
+
// Public Methods
|
|
1556
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
1557
|
+
async prepare(s) {
|
|
1558
|
+
return this.assertStatus(a.IDLE, "prepare"), this.act(async () => {
|
|
1559
|
+
const t = this.validatePrepareParams(s);
|
|
1560
|
+
if (this._amount = t.amount, this._recipient = t.recipient, this._referralCode = t.referralCode, this.authState.fee = await l.getStakeAndBakeFee(
|
|
1561
|
+
this.ctx,
|
|
1562
|
+
this.chainId,
|
|
1563
|
+
this.params.protocol
|
|
1564
|
+
), await this.resumeFromExistingDeposit(
|
|
1565
|
+
t.recipient
|
|
1566
|
+
)) {
|
|
1567
|
+
const d = await l.restoreStakeAndBakeSignature(
|
|
1568
|
+
this.ctx,
|
|
1569
|
+
this.chainId,
|
|
1570
|
+
t.recipient
|
|
1571
|
+
);
|
|
1572
|
+
if (d != null && d.hasSignature) {
|
|
1573
|
+
d.signature && (this.authState.signature = d.signature), this.authState.authorized = !0, this.updateStatus(a.ADDRESS_READY), this.emitInitialProgress();
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
this.updateStatus(a.NEEDS_DEPLOY_AUTHORIZATION), this.emitInitialProgress();
|
|
1577
|
+
return;
|
|
1578
|
+
}
|
|
1579
|
+
const r = await l.restoreStakeAndBakeSignature(
|
|
1580
|
+
this.ctx,
|
|
1581
|
+
this.chainId,
|
|
1582
|
+
t.recipient
|
|
1583
|
+
);
|
|
1584
|
+
if (r != null && r.hasSignature) {
|
|
1585
|
+
r.signature && (this.authState.signature = r.signature), this.authState.authorized = !0, this.updateStatus(a.READY), this.emitInitialProgress();
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1588
|
+
this.updateStatus(a.NEEDS_DEPLOY_AUTHORIZATION), this.emitInitialProgress();
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
async authorizeDeposit() {
|
|
1592
|
+
if (this.assertStatus(
|
|
1593
|
+
[a.NEEDS_DEPLOY_AUTHORIZATION, a.READY],
|
|
1594
|
+
"authorizeDeposit"
|
|
1595
|
+
), this.status === a.READY) return;
|
|
1596
|
+
const s = this.ensureRecipient(), t = this.ensureAmount();
|
|
1597
|
+
return this.act(async () => {
|
|
1598
|
+
const n = T(t), r = this.params.assetIn ?? f.BTC, d = await l.authorizeStakeAndBake(
|
|
1599
|
+
this.ctx,
|
|
1600
|
+
{
|
|
1601
|
+
chainId: this.chainId,
|
|
1602
|
+
recipient: s,
|
|
1603
|
+
amount: n.toString(),
|
|
1604
|
+
vaultKey: kt(this.params.protocol),
|
|
1605
|
+
token: r
|
|
1606
|
+
}
|
|
1607
|
+
);
|
|
1608
|
+
this.authState.signature = d.signature, this.authState.typedData = d.typedData, this.authState.authorized = !0;
|
|
1609
|
+
}, a.READY);
|
|
1610
|
+
}
|
|
1611
|
+
async generateDepositAddress() {
|
|
1612
|
+
return this.assertStatus(a.READY, "generateDepositAddress"), this.ensureAuthorized(), this._depositAddress ? this._depositAddress : this.act(async () => {
|
|
1613
|
+
const s = this.getDepositAddressParams(), t = await this.ctx.api.generateDepositAddress(s);
|
|
1614
|
+
return O(t), this._depositAddress = t, this.emitProgress({
|
|
1615
|
+
status: a.ADDRESS_READY,
|
|
1616
|
+
steps: {
|
|
1617
|
+
created: o.COMPLETE,
|
|
1618
|
+
verifying: o.IDLE,
|
|
1619
|
+
issuing: o.IDLE,
|
|
1620
|
+
depositing: o.IDLE
|
|
1621
|
+
},
|
|
1622
|
+
metadata: { depositAddress: t }
|
|
1623
|
+
}), t;
|
|
1624
|
+
}, a.ADDRESS_READY);
|
|
1625
|
+
}
|
|
1626
|
+
async execute() {
|
|
1627
|
+
return this.act(async () => {
|
|
1628
|
+
this.assertStatus(a.ADDRESS_READY, "execute"), this._depositAddress || await this.generateDepositAddress();
|
|
1629
|
+
const s = this.ensureDepositAddress(), t = await this.trySendBitcoin(s);
|
|
1630
|
+
return t ? { depositAddress: s, txHash: t } : { depositAddress: s };
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
// Custom monitorDeposit with different step names
|
|
1634
|
+
async monitorDeposit() {
|
|
1635
|
+
const s = this._depositAddress, t = this._recipient;
|
|
1636
|
+
if (!s || !t)
|
|
1637
|
+
throw u.missingParameter("depositAddress or recipient");
|
|
1638
|
+
return await B({
|
|
1639
|
+
network: this.bitcoinNetwork,
|
|
1640
|
+
btcService: this.ctx.btc,
|
|
1641
|
+
fetchDeposit: async () => {
|
|
1642
|
+
const d = (await this.ctx.api.getDeposits(t)).find(
|
|
1643
|
+
(A) => A.depositAddress === s
|
|
1644
|
+
);
|
|
1645
|
+
if (d)
|
|
1646
|
+
return {
|
|
1647
|
+
blockHeight: d.blockHeight,
|
|
1648
|
+
isClaimed: d.isClaimed
|
|
1649
|
+
};
|
|
1650
|
+
},
|
|
1651
|
+
onProgress: (r) => {
|
|
1652
|
+
this.emitProgress({
|
|
1653
|
+
status: this.status,
|
|
1654
|
+
steps: {
|
|
1655
|
+
created: o.COMPLETE,
|
|
1656
|
+
verifying: r.hasEnoughConfirmations ? o.COMPLETE : o.PENDING,
|
|
1657
|
+
issuing: r.isClaimed ? o.COMPLETE : o.PENDING,
|
|
1658
|
+
depositing: o.PENDING
|
|
1659
|
+
},
|
|
1660
|
+
confirmations: r.confirmations,
|
|
1661
|
+
requiredConfirmations: r.requiredConfirmations,
|
|
1662
|
+
metadata: { isClaimed: r.isClaimed }
|
|
1663
|
+
});
|
|
1664
|
+
},
|
|
1665
|
+
onComplete: () => {
|
|
1666
|
+
this.emitCompleted();
|
|
1667
|
+
}
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
class ne {
|
|
1672
|
+
constructor(i) {
|
|
1673
|
+
D(this, "ctx");
|
|
1674
|
+
this.ctx = at(i);
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* Stake BTC → LBTC
|
|
1678
|
+
*
|
|
1679
|
+
* Creates a stake operation for converting BTC to LBTC on a destination chain.
|
|
1680
|
+
* Supports all destination chains: EVM, Solana, Sui, and Starknet.
|
|
1681
|
+
*
|
|
1682
|
+
* @param params - Stake parameters
|
|
1683
|
+
* @returns BtcStake instance
|
|
1684
|
+
*
|
|
1685
|
+
* @example
|
|
1686
|
+
* ```typescript
|
|
1687
|
+
* const stake = btc.stake({
|
|
1688
|
+
* assetOut: AssetId.LBTC,
|
|
1689
|
+
* destChain: Chain.ETHEREUM,
|
|
1690
|
+
* });
|
|
1691
|
+
*
|
|
1692
|
+
* await stake.prepare({ amount: '0.1', recipient: '0x...' });
|
|
1693
|
+
* await stake.authorize();
|
|
1694
|
+
* const address = await stake.generateDepositAddress();
|
|
1695
|
+
* ```
|
|
1696
|
+
*/
|
|
1697
|
+
stake(i) {
|
|
1698
|
+
return new ie(this.ctx, i);
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Stake and Deploy BTC → LBTC + auto-deploy ("Stake and Bake")
|
|
1702
|
+
*
|
|
1703
|
+
* Creates an atomic operation that:
|
|
1704
|
+
* 1. Converts BTC to LBTC
|
|
1705
|
+
* 2. Automatically deposits LBTC to the specified DeFi vault
|
|
1706
|
+
*
|
|
1707
|
+
* @param params - StakeAndDeploy parameters including protocol/vault
|
|
1708
|
+
* @returns BtcStakeAndDeploy instance
|
|
1709
|
+
*
|
|
1710
|
+
* @example
|
|
1711
|
+
* ```typescript
|
|
1712
|
+
* const action = btc.stakeAndDeploy({
|
|
1713
|
+
* assetOut: AssetId.LBTC,
|
|
1714
|
+
* destChain: Chain.ETHEREUM,
|
|
1715
|
+
* protocol: DeployProtocol.Veda,
|
|
1716
|
+
* });
|
|
1717
|
+
*
|
|
1718
|
+
* await action.prepare({ amount: '0.1', recipient: '0x...' });
|
|
1719
|
+
* await action.authorizeDeposit();
|
|
1720
|
+
* const address = await action.generateDepositAddress();
|
|
1721
|
+
* ```
|
|
1722
|
+
*/
|
|
1723
|
+
stakeAndDeploy(i) {
|
|
1724
|
+
return new re(this.ctx, i);
|
|
1725
|
+
}
|
|
1726
|
+
/**
|
|
1727
|
+
* Deposit BTC for custody (BTC → BTC.b)
|
|
1728
|
+
*
|
|
1729
|
+
* Creates a deposit operation for custodying BTC with BTC.b minting.
|
|
1730
|
+
* This is for custody without staking. For staking (BTC → LBTC), use stake().
|
|
1731
|
+
*
|
|
1732
|
+
* @param params - Deposit parameters
|
|
1733
|
+
* @returns BtcDeposit instance
|
|
1734
|
+
*
|
|
1735
|
+
* @example
|
|
1736
|
+
* ```typescript
|
|
1737
|
+
* const deposit = btc.deposit({
|
|
1738
|
+
* assetOut: AssetId.BTCb,
|
|
1739
|
+
* destChain: Chain.AVALANCHE,
|
|
1740
|
+
* });
|
|
1741
|
+
*
|
|
1742
|
+
* await deposit.prepare({ amount: '0.1', recipient: '0x...' });
|
|
1743
|
+
* await deposit.authorizeFee();
|
|
1744
|
+
* const address = await deposit.generateDepositAddress();
|
|
1745
|
+
* ```
|
|
1746
|
+
*/
|
|
1747
|
+
deposit(i) {
|
|
1748
|
+
return new Nt(this.ctx, i);
|
|
1749
|
+
}
|
|
1750
|
+
/**
|
|
1751
|
+
* Deposit and Deploy BTC → BTC.b + auto-deploy to vault
|
|
1752
|
+
*
|
|
1753
|
+
* Creates an atomic operation that:
|
|
1754
|
+
* 1. Converts BTC to BTC.b (wrapped BTC)
|
|
1755
|
+
* 2. Automatically deposits BTC.b to the specified DeFi vault (e.g., Silo on Avalanche)
|
|
1756
|
+
*
|
|
1757
|
+
* This is similar to stakeAndDeploy but for protocols that accept BTC.b instead of LBTC.
|
|
1758
|
+
*
|
|
1759
|
+
* @param params - DepositAndDeploy parameters including protocol/vault
|
|
1760
|
+
* @returns BtcDepositAndDeploy instance
|
|
1761
|
+
*
|
|
1762
|
+
* @example
|
|
1763
|
+
* ```typescript
|
|
1764
|
+
* const action = btc.depositAndDeploy({
|
|
1765
|
+
* assetOut: AssetId.BTCb,
|
|
1766
|
+
* destChain: Chain.AVALANCHE,
|
|
1767
|
+
* protocol: DeployProtocol.Silo,
|
|
1768
|
+
* });
|
|
1769
|
+
*
|
|
1770
|
+
* await action.prepare({ amount: '0.1', recipient: '0x...' });
|
|
1771
|
+
* await action.authorizeDeposit();
|
|
1772
|
+
* const address = await action.generateDepositAddress();
|
|
1773
|
+
* ```
|
|
1774
|
+
*/
|
|
1775
|
+
depositAndDeploy(i) {
|
|
1776
|
+
return new Ht(this.ctx, i);
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
function le(e) {
|
|
1780
|
+
return new ne(e);
|
|
1781
|
+
}
|
|
1782
|
+
export {
|
|
1783
|
+
ne as B,
|
|
1784
|
+
Se as a,
|
|
1785
|
+
le as b,
|
|
1786
|
+
Nt as c,
|
|
1787
|
+
Ht as d,
|
|
1788
|
+
ie as e,
|
|
1789
|
+
re as f
|
|
1790
|
+
};
|
|
1791
|
+
//# sourceMappingURL=BtcActions-DGqmtxjd.js.map
|