@lombard.finance/sdk 4.1.0 → 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 +100 -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/lib/config.d.ts +3 -3
- package/dist/bridge/lib/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 +2 -2
- package/dist/common/chains.d.ts.map +1 -1
- package/dist/common/feature-config.d.ts +7 -7
- package/dist/contract-functions/getBasculeDepositStatus/getBasculeDepositStatus.d.ts.map +1 -1
- 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/lib/config.d.ts +1 -1
- 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 -48300
|
@@ -0,0 +1,1351 @@
|
|
|
1
|
+
var tt = Object.defineProperty;
|
|
2
|
+
var et = (n, a, t) => a in n ? tt(n, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[a] = t;
|
|
3
|
+
var u = (n, a, t) => et(n, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import w from "bignumber.js";
|
|
5
|
+
import { d as G, o as U, h as st, p as at, s as it, k as rt, r as z, j as nt, i as ot, l as ct } from "./unstakeLBTC-Huy_ncVl.js";
|
|
6
|
+
import { T as l, V as W, e as $, G as ht, f as Y } from "./token-addresses-DmAr89jP.js";
|
|
7
|
+
import { C as _, y as P, E as e, z as S, L as c, X as E, q as i, A as x, Y as ut, Z as L, _ as Z, $ as I, x as K, a0 as j, a1 as b, a2 as pt } from "./statusConstants-ZJia15m2.js";
|
|
8
|
+
import { e as V, m as O, t as y, g as M, f as q } from "./tokens-Bw35TZqd.js";
|
|
9
|
+
import { g as dt, s as mt } from "./storeNetworkFeeSignature-BZUZOxns.js";
|
|
10
|
+
import { r as vt } from "./fee-requirements-x8-8mpJ7.js";
|
|
11
|
+
import { D as T, A as m } from "./defi-registry-dhrQMy94.js";
|
|
12
|
+
import { r } from "./index-CfcQ_g3t.js";
|
|
13
|
+
import { t as Q } from "./numbers-CM-lcmt4.js";
|
|
14
|
+
import { c as B, a as D, b as X } from "./config-_8X_2sG4.js";
|
|
15
|
+
import { d as lt, c as Et, q as _t } from "./withdraw-CVNVJ7-x.js";
|
|
16
|
+
class Ct {
|
|
17
|
+
constructor(a) {
|
|
18
|
+
this.env = a;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get minting fee for a chain
|
|
22
|
+
* @param chainId - The chain ID
|
|
23
|
+
* @param token - Optional token (defaults to LBTC). Use Token.BTCb for BTC.b deposits.
|
|
24
|
+
*/
|
|
25
|
+
async getMintingFee(a, t) {
|
|
26
|
+
return (await G({
|
|
27
|
+
token: t || l.LBTC,
|
|
28
|
+
chainId: a,
|
|
29
|
+
env: this.env
|
|
30
|
+
})).toString();
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Sign network fee authorization (EIP-712)
|
|
34
|
+
*/
|
|
35
|
+
async signNetworkFee(a) {
|
|
36
|
+
const t = await U({
|
|
37
|
+
fee: new w(a.fee),
|
|
38
|
+
account: a.account,
|
|
39
|
+
chainId: a.chainId,
|
|
40
|
+
provider: a.provider,
|
|
41
|
+
env: this.env,
|
|
42
|
+
// Pass token for signing - defaults to LBTC for backwards compatibility
|
|
43
|
+
token: a.token ?? l.LBTC
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
signature: t.signature,
|
|
47
|
+
typedData: t.typedData
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get stake and bake fee for a vault
|
|
52
|
+
*/
|
|
53
|
+
async getStakeAndBakeFee(a, t) {
|
|
54
|
+
return (await st({
|
|
55
|
+
chainId: a,
|
|
56
|
+
protocol: t
|
|
57
|
+
})).toString();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Sign stake and bake authorization
|
|
61
|
+
*/
|
|
62
|
+
async signStakeAndBake(a) {
|
|
63
|
+
const t = await at({
|
|
64
|
+
value: new w(a.value),
|
|
65
|
+
account: a.account,
|
|
66
|
+
chainId: a.chainId,
|
|
67
|
+
provider: a.provider,
|
|
68
|
+
env: this.env,
|
|
69
|
+
vaultKey: a.vaultKey,
|
|
70
|
+
token: a.token
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
signature: t.signature,
|
|
74
|
+
typedData: t.typedData
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sign LBTC destination address (for non-Ethereum EVM chains)
|
|
79
|
+
*/
|
|
80
|
+
async signLbtcDestination(a) {
|
|
81
|
+
return { signature: await it({
|
|
82
|
+
account: a.address,
|
|
83
|
+
chainId: a.chainId,
|
|
84
|
+
provider: a.provider
|
|
85
|
+
}) };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function ue() {
|
|
89
|
+
return {
|
|
90
|
+
id: "evm",
|
|
91
|
+
chain: "evm",
|
|
92
|
+
register(n) {
|
|
93
|
+
return new Ct(n.env);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const gt = {
|
|
98
|
+
routes: [
|
|
99
|
+
// Veda - Ethereum
|
|
100
|
+
{
|
|
101
|
+
asset: m.LBTC,
|
|
102
|
+
sourceChains: [_.ETHEREUM],
|
|
103
|
+
protocols: [T.Veda],
|
|
104
|
+
envs: [r.prod]
|
|
105
|
+
},
|
|
106
|
+
// Veda - Base
|
|
107
|
+
{
|
|
108
|
+
asset: m.LBTC,
|
|
109
|
+
sourceChains: [_.BASE],
|
|
110
|
+
protocols: [T.Veda],
|
|
111
|
+
envs: [r.prod]
|
|
112
|
+
},
|
|
113
|
+
// Veda - BSC
|
|
114
|
+
{
|
|
115
|
+
asset: m.LBTC,
|
|
116
|
+
sourceChains: [_.BSC],
|
|
117
|
+
protocols: [T.Veda],
|
|
118
|
+
envs: [r.prod]
|
|
119
|
+
},
|
|
120
|
+
// Veda - Corn
|
|
121
|
+
{
|
|
122
|
+
asset: m.LBTC,
|
|
123
|
+
sourceChains: [_.CORN],
|
|
124
|
+
protocols: [T.Veda],
|
|
125
|
+
envs: [r.prod]
|
|
126
|
+
},
|
|
127
|
+
// Silo - Avalanche
|
|
128
|
+
{
|
|
129
|
+
asset: m.LBTC,
|
|
130
|
+
sourceChains: [_.AVALANCHE],
|
|
131
|
+
protocols: [T.Silo],
|
|
132
|
+
envs: [r.prod]
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
};
|
|
136
|
+
class At extends P {
|
|
137
|
+
constructor(t, s) {
|
|
138
|
+
super(e.IDLE);
|
|
139
|
+
u(this, "_amount");
|
|
140
|
+
u(this, "_protocol");
|
|
141
|
+
u(this, "_needsApproval", !1);
|
|
142
|
+
u(this, "_txHash");
|
|
143
|
+
u(this, "_account");
|
|
144
|
+
u(this, "_chainId");
|
|
145
|
+
this.ctx = t, this.params = s;
|
|
146
|
+
}
|
|
147
|
+
get amount() {
|
|
148
|
+
return this._amount;
|
|
149
|
+
}
|
|
150
|
+
get protocol() {
|
|
151
|
+
return this._protocol;
|
|
152
|
+
}
|
|
153
|
+
get needsApproval() {
|
|
154
|
+
return this._needsApproval;
|
|
155
|
+
}
|
|
156
|
+
get txHash() {
|
|
157
|
+
return this._txHash;
|
|
158
|
+
}
|
|
159
|
+
async prepare(t) {
|
|
160
|
+
return this.assertStatus(e.IDLE, "prepare"), this.act(async () => {
|
|
161
|
+
const s = S(this.prepareSchema, t);
|
|
162
|
+
this._amount = s.amount, this._protocol = t.protocol, this.validateProtocol(t.protocol);
|
|
163
|
+
const o = await this.ctx.getProvider("evm");
|
|
164
|
+
if (!o)
|
|
165
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
166
|
+
const p = (await o.request({
|
|
167
|
+
method: "eth_accounts"
|
|
168
|
+
}))[0];
|
|
169
|
+
if (!p)
|
|
170
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
171
|
+
this._account = p, this._chainId = E(this.params.sourceChain);
|
|
172
|
+
const v = B[D.Veda], h = await V(l.LBTC, this._chainId, this.ctx.env);
|
|
173
|
+
if (!h)
|
|
174
|
+
throw c.invalidParameter("token", "Could not get LBTC token info");
|
|
175
|
+
const C = await O({ chainId: this._chainId }).readContract({
|
|
176
|
+
address: h.address,
|
|
177
|
+
abi: h.abi,
|
|
178
|
+
functionName: "allowance",
|
|
179
|
+
args: [p, v.vaultContract.address]
|
|
180
|
+
}), f = new w(s.amount), N = y(f, h.decimals), R = new w(String(C));
|
|
181
|
+
this._needsApproval = N.isGreaterThan(R), this._needsApproval ? (this.emitProgress({
|
|
182
|
+
status: e.NEEDS_APPROVAL,
|
|
183
|
+
steps: { approval: i.PENDING, deploying: i.IDLE }
|
|
184
|
+
}), this.updateStatus(e.NEEDS_APPROVAL)) : (this.emitProgress({
|
|
185
|
+
status: e.READY,
|
|
186
|
+
steps: { approval: i.COMPLETE, deploying: i.PENDING }
|
|
187
|
+
}), this.updateStatus(e.READY));
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
async approve() {
|
|
191
|
+
return this.assertStatus(e.NEEDS_APPROVAL, "approve"), this.act(async () => {
|
|
192
|
+
if (!this._account || !this._chainId || !this._amount)
|
|
193
|
+
throw c.missingParameter("account, chainId, or amount");
|
|
194
|
+
const t = await this.ctx.getProvider("evm");
|
|
195
|
+
if (!t)
|
|
196
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
197
|
+
const s = B[D.Veda], o = await V(l.LBTC, this._chainId, this.ctx.env);
|
|
198
|
+
if (!o)
|
|
199
|
+
throw c.invalidParameter("token", "Could not get LBTC token info");
|
|
200
|
+
const d = new w(this._amount), p = Q(y(d, o.decimals)), v = O({ chainId: this._chainId }), h = W({
|
|
201
|
+
provider: t,
|
|
202
|
+
chainId: this._chainId
|
|
203
|
+
}), { request: A } = await v.simulateContract({
|
|
204
|
+
account: this._account,
|
|
205
|
+
chain: $[this._chainId],
|
|
206
|
+
address: o.address,
|
|
207
|
+
abi: o.abi,
|
|
208
|
+
functionName: "approve",
|
|
209
|
+
args: [s.vaultContract.address, p]
|
|
210
|
+
});
|
|
211
|
+
await h.writeContract(A), this._needsApproval = !1, this.emitProgress({
|
|
212
|
+
status: e.READY,
|
|
213
|
+
steps: { approval: i.COMPLETE, deploying: i.PENDING }
|
|
214
|
+
});
|
|
215
|
+
}, e.READY);
|
|
216
|
+
}
|
|
217
|
+
async execute() {
|
|
218
|
+
return this.assertStatus(e.READY, "execute"), this.act(async () => {
|
|
219
|
+
const t = await this.ctx.getProvider("evm");
|
|
220
|
+
if (!t)
|
|
221
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
222
|
+
if (!this._account || !this._chainId)
|
|
223
|
+
throw c.missingParameter("account or chainId");
|
|
224
|
+
const s = this._protocol === "veda" ? D.Veda : D.Veda;
|
|
225
|
+
this.emitProgress({
|
|
226
|
+
status: e.READY,
|
|
227
|
+
steps: { approval: i.COMPLETE, deploying: i.PENDING }
|
|
228
|
+
});
|
|
229
|
+
const o = await lt({
|
|
230
|
+
amount: this._amount,
|
|
231
|
+
approve: !1,
|
|
232
|
+
// Approval was handled in approve() step
|
|
233
|
+
token: l.LBTC,
|
|
234
|
+
vaultKey: s,
|
|
235
|
+
account: this._account,
|
|
236
|
+
chainId: this._chainId,
|
|
237
|
+
provider: t,
|
|
238
|
+
env: this.ctx.env
|
|
239
|
+
});
|
|
240
|
+
return this._txHash = o, this.emitProgress({
|
|
241
|
+
status: e.COMPLETED,
|
|
242
|
+
steps: { approval: i.COMPLETE, deploying: i.COMPLETE }
|
|
243
|
+
}), this.emitCompleted(), { txHash: o };
|
|
244
|
+
}, e.COMPLETED);
|
|
245
|
+
}
|
|
246
|
+
get prepareSchema() {
|
|
247
|
+
return x({
|
|
248
|
+
amount: L,
|
|
249
|
+
protocol: ut().min(1, "Protocol is required")
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
validateProtocol(t) {
|
|
253
|
+
if (!gt.routes.some(
|
|
254
|
+
(o) => o.protocols.includes(t) && o.envs.includes(this.ctx.env)
|
|
255
|
+
))
|
|
256
|
+
throw c.invalidParameter(
|
|
257
|
+
"protocol",
|
|
258
|
+
`Protocol ${t} is not supported in ${this.ctx.env} environment`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function It(n, a) {
|
|
263
|
+
return new At(n, a);
|
|
264
|
+
}
|
|
265
|
+
const ft = [
|
|
266
|
+
.../* @__PURE__ */ new Set([
|
|
267
|
+
...I(m.WBTC, [r.prod]),
|
|
268
|
+
...I(m.BTCb, [r.prod])
|
|
269
|
+
])
|
|
270
|
+
], Dt = [
|
|
271
|
+
.../* @__PURE__ */ new Set([
|
|
272
|
+
...I(m.WBTC, [r.testnet, r.stage, r.dev, r.ibc]),
|
|
273
|
+
...I(m.BTCb, [r.testnet, r.stage, r.dev, r.ibc])
|
|
274
|
+
])
|
|
275
|
+
], wt = I(m.LBTC, [r.prod]), Pt = I(m.LBTC, [
|
|
276
|
+
r.testnet,
|
|
277
|
+
r.stage,
|
|
278
|
+
r.dev,
|
|
279
|
+
r.ibc
|
|
280
|
+
]), Tt = {
|
|
281
|
+
routes: [
|
|
282
|
+
// Production: WBTC/BTCb → LBTC
|
|
283
|
+
{
|
|
284
|
+
assetsIn: [m.WBTC, m.BTCb],
|
|
285
|
+
assetOut: m.LBTC,
|
|
286
|
+
sourceChains: ft,
|
|
287
|
+
destChains: wt,
|
|
288
|
+
envs: [r.prod]
|
|
289
|
+
},
|
|
290
|
+
// Testnet
|
|
291
|
+
{
|
|
292
|
+
assetsIn: [m.WBTC, m.BTCb],
|
|
293
|
+
assetOut: m.LBTC,
|
|
294
|
+
sourceChains: Dt,
|
|
295
|
+
destChains: Pt,
|
|
296
|
+
envs: [r.testnet, r.stage, r.dev, r.ibc]
|
|
297
|
+
}
|
|
298
|
+
],
|
|
299
|
+
addressSchema: Z
|
|
300
|
+
};
|
|
301
|
+
var g = /* @__PURE__ */ ((n) => (n.IDLE = "idle", n.NEEDS_APPROVAL = "needs-approval", n.READY = "ready", n.BRIDGING = "bridging", n.COMPLETED = "completed", n))(g || {});
|
|
302
|
+
class St extends P {
|
|
303
|
+
constructor(t, s) {
|
|
304
|
+
super(g.IDLE);
|
|
305
|
+
u(this, "_amount");
|
|
306
|
+
u(this, "_recipient");
|
|
307
|
+
u(this, "_needsApproval", !1);
|
|
308
|
+
u(this, "_txHash");
|
|
309
|
+
u(this, "_claimData");
|
|
310
|
+
this.ctx = t, this.params = s;
|
|
311
|
+
}
|
|
312
|
+
get amount() {
|
|
313
|
+
return this._amount;
|
|
314
|
+
}
|
|
315
|
+
get recipient() {
|
|
316
|
+
return this._recipient;
|
|
317
|
+
}
|
|
318
|
+
get needsApproval() {
|
|
319
|
+
return this._needsApproval;
|
|
320
|
+
}
|
|
321
|
+
get txHash() {
|
|
322
|
+
return this._txHash;
|
|
323
|
+
}
|
|
324
|
+
setClaimData(t, s) {
|
|
325
|
+
this._claimData = { data: t, proofSignature: s };
|
|
326
|
+
}
|
|
327
|
+
async prepare(t) {
|
|
328
|
+
return this.assertStatus(g.IDLE, "prepare"), this.act(async () => {
|
|
329
|
+
const s = S(this.prepareSchema, t, {
|
|
330
|
+
destChain: this.params.destChain
|
|
331
|
+
});
|
|
332
|
+
this._amount = s.amount, this._recipient = s.recipient, this._needsApproval = !1, this.emitProgress({
|
|
333
|
+
status: g.READY,
|
|
334
|
+
steps: {
|
|
335
|
+
approval: i.COMPLETE,
|
|
336
|
+
execution: i.IDLE,
|
|
337
|
+
bridging: i.IDLE
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}, g.READY);
|
|
341
|
+
}
|
|
342
|
+
async approve() {
|
|
343
|
+
return this.assertStatus(g.NEEDS_APPROVAL, "approve"), this.act(async () => {
|
|
344
|
+
this._needsApproval = !1;
|
|
345
|
+
}, g.READY);
|
|
346
|
+
}
|
|
347
|
+
async execute() {
|
|
348
|
+
if (this.assertStatus(g.READY, "execute"), !this._claimData)
|
|
349
|
+
throw c.missingParameter("claimData");
|
|
350
|
+
return this.act(async () => {
|
|
351
|
+
const t = await this.ctx.getProvider("evm");
|
|
352
|
+
if (!t)
|
|
353
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
354
|
+
const s = E(this.params.destChain);
|
|
355
|
+
this.emitProgress({
|
|
356
|
+
status: g.READY,
|
|
357
|
+
steps: {
|
|
358
|
+
approval: i.COMPLETE,
|
|
359
|
+
execution: i.PENDING,
|
|
360
|
+
bridging: i.IDLE
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
const o = await rt({
|
|
364
|
+
provider: t,
|
|
365
|
+
account: this._recipient,
|
|
366
|
+
data: this._claimData.data,
|
|
367
|
+
proofSignature: this._claimData.proofSignature,
|
|
368
|
+
chainId: s,
|
|
369
|
+
env: this.ctx.env
|
|
370
|
+
});
|
|
371
|
+
return this._txHash = o, this.emitProgress({
|
|
372
|
+
status: g.COMPLETED,
|
|
373
|
+
steps: {
|
|
374
|
+
approval: i.COMPLETE,
|
|
375
|
+
execution: i.COMPLETE,
|
|
376
|
+
bridging: i.IDLE
|
|
377
|
+
}
|
|
378
|
+
}), this.emitCompleted(), { txHash: o };
|
|
379
|
+
}, g.COMPLETED);
|
|
380
|
+
}
|
|
381
|
+
get prepareSchema() {
|
|
382
|
+
return x({
|
|
383
|
+
amount: L,
|
|
384
|
+
recipient: Tt.addressSchema
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function xt(n, a) {
|
|
389
|
+
return new St(n, a);
|
|
390
|
+
}
|
|
391
|
+
const Lt = I(m.BTCb, [r.prod]), Nt = I(m.BTCb, [
|
|
392
|
+
r.testnet,
|
|
393
|
+
r.stage,
|
|
394
|
+
r.dev,
|
|
395
|
+
r.ibc
|
|
396
|
+
]), Ot = {
|
|
397
|
+
routes: [
|
|
398
|
+
// BTC.b → BTC (to Bitcoin Mainnet)
|
|
399
|
+
{
|
|
400
|
+
assetIn: m.BTCb,
|
|
401
|
+
assetOut: m.BTC,
|
|
402
|
+
sourceChains: Lt,
|
|
403
|
+
destChain: _.BITCOIN_MAINNET,
|
|
404
|
+
envs: [r.prod]
|
|
405
|
+
},
|
|
406
|
+
// BTC.b → BTC (to Bitcoin Signet - testnet)
|
|
407
|
+
{
|
|
408
|
+
assetIn: m.BTCb,
|
|
409
|
+
assetOut: m.BTC,
|
|
410
|
+
sourceChains: Nt,
|
|
411
|
+
destChain: _.BITCOIN_SIGNET,
|
|
412
|
+
envs: [r.testnet, r.stage, r.dev, r.ibc]
|
|
413
|
+
}
|
|
414
|
+
// TODO: Add L-Asset routes when deployed
|
|
415
|
+
// L-ZEC → ZEC, L-SOL → SOL, L-XRP → XRP, L-DOGE → DOGE
|
|
416
|
+
],
|
|
417
|
+
recipientSchema: K
|
|
418
|
+
};
|
|
419
|
+
async function k(n, a, t, s) {
|
|
420
|
+
if (!vt(n))
|
|
421
|
+
return {
|
|
422
|
+
requiresAuth: !1,
|
|
423
|
+
hasValidSignature: !1,
|
|
424
|
+
feeInSatoshis: null,
|
|
425
|
+
feeFormatted: null,
|
|
426
|
+
expirationDate: null
|
|
427
|
+
};
|
|
428
|
+
const o = await M(s, n, t), d = await dt({
|
|
429
|
+
address: a,
|
|
430
|
+
chainId: n,
|
|
431
|
+
env: t,
|
|
432
|
+
tokenAddress: o.address
|
|
433
|
+
}), p = d.expirationDate ? new Date(Number(d.expirationDate) * 1e3) < /* @__PURE__ */ new Date() : !1, v = d.hasSignature && !p;
|
|
434
|
+
let h = null, A = null;
|
|
435
|
+
if (!v) {
|
|
436
|
+
const C = await G({
|
|
437
|
+
token: s,
|
|
438
|
+
chainId: n,
|
|
439
|
+
env: t
|
|
440
|
+
});
|
|
441
|
+
h = BigInt(C.times(1e8).toFixed(0)), A = C.toFixed(8);
|
|
442
|
+
}
|
|
443
|
+
return {
|
|
444
|
+
requiresAuth: !0,
|
|
445
|
+
hasValidSignature: v,
|
|
446
|
+
feeInSatoshis: h,
|
|
447
|
+
feeFormatted: A,
|
|
448
|
+
expirationDate: d.expirationDate ?? null
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
async function H(n) {
|
|
452
|
+
const { chainId: a, account: t, feeInSatoshis: s, provider: o, env: d, token: p } = n, v = await M(p, a, d), h = await U({
|
|
453
|
+
fee: s,
|
|
454
|
+
account: t,
|
|
455
|
+
chainId: a,
|
|
456
|
+
provider: o,
|
|
457
|
+
env: d,
|
|
458
|
+
token: p
|
|
459
|
+
});
|
|
460
|
+
return await mt({
|
|
461
|
+
signature: h.signature,
|
|
462
|
+
typedData: h.typedData,
|
|
463
|
+
address: t,
|
|
464
|
+
env: d,
|
|
465
|
+
tokenAddress: v.address
|
|
466
|
+
}), h;
|
|
467
|
+
}
|
|
468
|
+
function F() {
|
|
469
|
+
return {
|
|
470
|
+
requiresAuth: !1,
|
|
471
|
+
isAuthorized: !1,
|
|
472
|
+
feeInSatoshis: null,
|
|
473
|
+
feeFormatted: null,
|
|
474
|
+
expirationDate: null
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
class Bt extends P {
|
|
478
|
+
constructor(t, s) {
|
|
479
|
+
super(e.IDLE);
|
|
480
|
+
u(this, "_amount");
|
|
481
|
+
u(this, "_recipient");
|
|
482
|
+
u(this, "_needsApproval", !1);
|
|
483
|
+
u(this, "_txHash");
|
|
484
|
+
u(this, "_feeAuth", F());
|
|
485
|
+
this.ctx = t, this.params = s;
|
|
486
|
+
}
|
|
487
|
+
get amount() {
|
|
488
|
+
return this._amount;
|
|
489
|
+
}
|
|
490
|
+
get recipient() {
|
|
491
|
+
return this._recipient;
|
|
492
|
+
}
|
|
493
|
+
get needsApproval() {
|
|
494
|
+
return this._needsApproval;
|
|
495
|
+
}
|
|
496
|
+
get txHash() {
|
|
497
|
+
return this._txHash;
|
|
498
|
+
}
|
|
499
|
+
/** Fee authorization state (for UI display) */
|
|
500
|
+
get feeAuth() {
|
|
501
|
+
return this._feeAuth;
|
|
502
|
+
}
|
|
503
|
+
async prepare(t) {
|
|
504
|
+
return this.assertStatus(e.IDLE, "prepare"), this.act(async () => {
|
|
505
|
+
const s = S(this.prepareSchema, t, {
|
|
506
|
+
destChain: this.params.destChain
|
|
507
|
+
});
|
|
508
|
+
this._amount = s.amount, this._recipient = s.recipient;
|
|
509
|
+
const o = E(this.params.sourceChain), d = await this.ctx.getProvider("evm");
|
|
510
|
+
if (!d)
|
|
511
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
512
|
+
const v = (await d.request({
|
|
513
|
+
method: "eth_accounts"
|
|
514
|
+
}))[0], h = await k(
|
|
515
|
+
o,
|
|
516
|
+
v,
|
|
517
|
+
this.ctx.env,
|
|
518
|
+
l.BTCb
|
|
519
|
+
);
|
|
520
|
+
if (this._feeAuth = {
|
|
521
|
+
requiresAuth: h.requiresAuth,
|
|
522
|
+
isAuthorized: h.hasValidSignature,
|
|
523
|
+
feeInSatoshis: h.feeInSatoshis,
|
|
524
|
+
feeFormatted: h.feeFormatted,
|
|
525
|
+
expirationDate: h.expirationDate
|
|
526
|
+
}, h.requiresAuth && !h.hasValidSignature) {
|
|
527
|
+
this.emitProgress({
|
|
528
|
+
status: e.NEEDS_FEE_AUTHORIZATION,
|
|
529
|
+
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
530
|
+
});
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
this._needsApproval = !1, this.emitProgress({
|
|
534
|
+
status: e.READY,
|
|
535
|
+
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
536
|
+
});
|
|
537
|
+
}, this._feeAuth.requiresAuth && !this._feeAuth.isAuthorized ? e.NEEDS_FEE_AUTHORIZATION : e.READY);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Authorize the network fee
|
|
541
|
+
*
|
|
542
|
+
* Must be called when status is NEEDS_FEE_AUTHORIZATION.
|
|
543
|
+
* Signs the fee authorization and stores it on the server.
|
|
544
|
+
*/
|
|
545
|
+
async authorizeFee() {
|
|
546
|
+
if (this.assertStatus(e.NEEDS_FEE_AUTHORIZATION, "authorizeFee"), !this._feeAuth.feeInSatoshis)
|
|
547
|
+
throw c.missingParameter("feeInSatoshis");
|
|
548
|
+
return this.act(async () => {
|
|
549
|
+
const t = E(this.params.sourceChain), s = await this.ctx.getProvider("evm");
|
|
550
|
+
if (!s)
|
|
551
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
552
|
+
const d = (await s.request({
|
|
553
|
+
method: "eth_accounts"
|
|
554
|
+
}))[0];
|
|
555
|
+
await H({
|
|
556
|
+
chainId: t,
|
|
557
|
+
account: d,
|
|
558
|
+
feeInSatoshis: this._feeAuth.feeInSatoshis,
|
|
559
|
+
provider: s,
|
|
560
|
+
env: this.ctx.env,
|
|
561
|
+
token: l.BTCb
|
|
562
|
+
}), this._feeAuth.isAuthorized = !0, this.emitProgress({
|
|
563
|
+
status: e.READY,
|
|
564
|
+
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
565
|
+
});
|
|
566
|
+
}, e.READY);
|
|
567
|
+
}
|
|
568
|
+
async approve() {
|
|
569
|
+
return this.assertStatus(e.NEEDS_APPROVAL, "approve"), this.act(async () => {
|
|
570
|
+
this._needsApproval = !1, this.emitProgress({
|
|
571
|
+
status: e.READY,
|
|
572
|
+
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
573
|
+
});
|
|
574
|
+
}, e.READY);
|
|
575
|
+
}
|
|
576
|
+
async execute() {
|
|
577
|
+
return this.assertStatus(e.READY, "execute"), this.act(async () => {
|
|
578
|
+
const t = await this.ctx.getProvider("evm");
|
|
579
|
+
if (!t)
|
|
580
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
581
|
+
const o = (await t.request({
|
|
582
|
+
method: "eth_accounts"
|
|
583
|
+
}))[0];
|
|
584
|
+
if (!o)
|
|
585
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
586
|
+
const d = E(this.params.sourceChain);
|
|
587
|
+
this.emitProgress({
|
|
588
|
+
status: e.READY,
|
|
589
|
+
steps: { burning: i.PENDING, releasing: i.IDLE }
|
|
590
|
+
});
|
|
591
|
+
const p = await z({
|
|
592
|
+
provider: t,
|
|
593
|
+
account: o,
|
|
594
|
+
amount: this._amount,
|
|
595
|
+
btcAddress: this._recipient,
|
|
596
|
+
// Bitcoin address to receive BTC
|
|
597
|
+
chainId: d,
|
|
598
|
+
env: this.ctx.env,
|
|
599
|
+
tokenIn: l.BTCb,
|
|
600
|
+
tokenOut: void 0
|
|
601
|
+
// Native BTC output
|
|
602
|
+
});
|
|
603
|
+
return this._txHash = p, this.emitProgress({
|
|
604
|
+
status: e.COMPLETED,
|
|
605
|
+
steps: { burning: i.COMPLETE, releasing: i.PENDING }
|
|
606
|
+
}), this.emitCompleted(), { txHash: p };
|
|
607
|
+
}, e.COMPLETED);
|
|
608
|
+
}
|
|
609
|
+
get prepareSchema() {
|
|
610
|
+
return x({
|
|
611
|
+
amount: L,
|
|
612
|
+
recipient: Ot.recipientSchema
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
function Rt(n, a) {
|
|
617
|
+
return new Bt(n, a);
|
|
618
|
+
}
|
|
619
|
+
const bt = [
|
|
620
|
+
Y.avalanche,
|
|
621
|
+
Y.avalancheFuji
|
|
622
|
+
];
|
|
623
|
+
function yt(n) {
|
|
624
|
+
return bt.includes(n);
|
|
625
|
+
}
|
|
626
|
+
class Mt extends P {
|
|
627
|
+
constructor(t, s) {
|
|
628
|
+
super(e.IDLE);
|
|
629
|
+
u(this, "_amount");
|
|
630
|
+
u(this, "_txHash");
|
|
631
|
+
u(this, "_feeAuth", F());
|
|
632
|
+
u(this, "_account");
|
|
633
|
+
u(this, "_needsApproval", !1);
|
|
634
|
+
u(this, "_spenderAddress");
|
|
635
|
+
this.ctx = t, this.params = s;
|
|
636
|
+
}
|
|
637
|
+
get amount() {
|
|
638
|
+
return this._amount;
|
|
639
|
+
}
|
|
640
|
+
get txHash() {
|
|
641
|
+
return this._txHash;
|
|
642
|
+
}
|
|
643
|
+
/** Fee authorization state (for UI display) */
|
|
644
|
+
get feeAuth() {
|
|
645
|
+
return this._feeAuth;
|
|
646
|
+
}
|
|
647
|
+
/** Whether approval is needed */
|
|
648
|
+
get needsApproval() {
|
|
649
|
+
return this._needsApproval;
|
|
650
|
+
}
|
|
651
|
+
async prepare(t) {
|
|
652
|
+
return this.assertStatus(e.IDLE, "prepare"), this.act(async () => {
|
|
653
|
+
const s = S(this.prepareSchema, t);
|
|
654
|
+
this._amount = s.amount;
|
|
655
|
+
const o = await this.ctx.getProvider("evm");
|
|
656
|
+
if (!o)
|
|
657
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
658
|
+
const p = (await o.request({
|
|
659
|
+
method: "eth_accounts"
|
|
660
|
+
}))[0];
|
|
661
|
+
if (!p)
|
|
662
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
663
|
+
this._account = p;
|
|
664
|
+
const v = E(this.params.sourceChain);
|
|
665
|
+
if (yt(v)) {
|
|
666
|
+
const C = await M(
|
|
667
|
+
l.BTCb,
|
|
668
|
+
v,
|
|
669
|
+
this.ctx.env,
|
|
670
|
+
ht.Adapter
|
|
671
|
+
);
|
|
672
|
+
this._spenderAddress = C.address;
|
|
673
|
+
const f = await nt({
|
|
674
|
+
token: l.BTCb,
|
|
675
|
+
owner: p,
|
|
676
|
+
spender: C.address,
|
|
677
|
+
chainId: v,
|
|
678
|
+
env: this.ctx.env
|
|
679
|
+
}), N = new w(s.amount);
|
|
680
|
+
if (this._needsApproval = f.isLessThan(N), this._needsApproval) {
|
|
681
|
+
this.emitProgress({
|
|
682
|
+
status: e.NEEDS_APPROVAL,
|
|
683
|
+
steps: { approval: i.PENDING, staking: i.IDLE }
|
|
684
|
+
}), this.updateStatus(e.NEEDS_APPROVAL);
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
const h = await k(
|
|
689
|
+
v,
|
|
690
|
+
p,
|
|
691
|
+
this.ctx.env,
|
|
692
|
+
l.LBTC
|
|
693
|
+
);
|
|
694
|
+
this._feeAuth = {
|
|
695
|
+
requiresAuth: h.requiresAuth,
|
|
696
|
+
isAuthorized: h.hasValidSignature,
|
|
697
|
+
feeInSatoshis: h.feeInSatoshis,
|
|
698
|
+
feeFormatted: h.feeFormatted,
|
|
699
|
+
expirationDate: h.expirationDate
|
|
700
|
+
}, h.requiresAuth && !h.hasValidSignature ? (this.emitProgress({
|
|
701
|
+
status: e.NEEDS_FEE_AUTHORIZATION,
|
|
702
|
+
steps: { staking: i.IDLE }
|
|
703
|
+
}), this.updateStatus(e.NEEDS_FEE_AUTHORIZATION)) : (this.emitProgress({
|
|
704
|
+
status: e.READY,
|
|
705
|
+
steps: { staking: i.PENDING }
|
|
706
|
+
}), this.updateStatus(e.READY));
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Approve BTC.b spending (Avalanche only)
|
|
711
|
+
*
|
|
712
|
+
* Must be called when status is NEEDS_APPROVAL.
|
|
713
|
+
*/
|
|
714
|
+
async approve() {
|
|
715
|
+
return this.assertStatus(e.NEEDS_APPROVAL, "approve"), this.act(async () => {
|
|
716
|
+
if (!this._account || !this._spenderAddress || !this._amount)
|
|
717
|
+
throw c.missingParameter(
|
|
718
|
+
"account, spenderAddress, or amount"
|
|
719
|
+
);
|
|
720
|
+
const t = await this.ctx.getProvider("evm");
|
|
721
|
+
if (!t)
|
|
722
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
723
|
+
const s = E(this.params.sourceChain);
|
|
724
|
+
await ot({
|
|
725
|
+
account: this._account,
|
|
726
|
+
token: l.BTCb,
|
|
727
|
+
spender: this._spenderAddress,
|
|
728
|
+
amount: this._amount,
|
|
729
|
+
chainId: s,
|
|
730
|
+
provider: t,
|
|
731
|
+
env: this.ctx.env
|
|
732
|
+
}), this._needsApproval = !1, this.emitProgress({
|
|
733
|
+
status: e.READY,
|
|
734
|
+
steps: { approval: i.COMPLETE, staking: i.PENDING }
|
|
735
|
+
});
|
|
736
|
+
}, e.READY);
|
|
737
|
+
}
|
|
738
|
+
async authorizeFee() {
|
|
739
|
+
return this.assertStatus(
|
|
740
|
+
e.NEEDS_FEE_AUTHORIZATION,
|
|
741
|
+
"authorizeFee"
|
|
742
|
+
), this.act(async () => {
|
|
743
|
+
if (!this._feeAuth.feeInSatoshis)
|
|
744
|
+
throw c.missingParameter("feeInSatoshis");
|
|
745
|
+
const t = await this.ctx.getProvider("evm");
|
|
746
|
+
if (!t)
|
|
747
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
748
|
+
const s = E(this.params.sourceChain);
|
|
749
|
+
await H({
|
|
750
|
+
chainId: s,
|
|
751
|
+
account: this._account,
|
|
752
|
+
feeInSatoshis: this._feeAuth.feeInSatoshis,
|
|
753
|
+
provider: t,
|
|
754
|
+
env: this.ctx.env,
|
|
755
|
+
token: l.LBTC
|
|
756
|
+
// BTC.b → LBTC uses LBTC token for fee signature
|
|
757
|
+
}), this._feeAuth = {
|
|
758
|
+
...this._feeAuth,
|
|
759
|
+
isAuthorized: !0
|
|
760
|
+
}, this.emitProgress({
|
|
761
|
+
status: e.READY,
|
|
762
|
+
steps: { staking: i.PENDING }
|
|
763
|
+
});
|
|
764
|
+
}, e.READY);
|
|
765
|
+
}
|
|
766
|
+
async execute() {
|
|
767
|
+
return this.assertStatus(e.READY, "execute"), this.act(async () => {
|
|
768
|
+
const t = await this.ctx.getProvider("evm");
|
|
769
|
+
if (!t)
|
|
770
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
771
|
+
const s = E(this.params.sourceChain), d = (await t.request({
|
|
772
|
+
method: "eth_accounts"
|
|
773
|
+
}))[0];
|
|
774
|
+
if (!d)
|
|
775
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
776
|
+
this.emitProgress({
|
|
777
|
+
status: e.READY,
|
|
778
|
+
steps: { staking: i.PENDING }
|
|
779
|
+
});
|
|
780
|
+
const p = await ct({
|
|
781
|
+
amount: this._amount,
|
|
782
|
+
tokenIn: l.BTCb,
|
|
783
|
+
tokenOut: l.LBTC,
|
|
784
|
+
account: d,
|
|
785
|
+
chainId: s,
|
|
786
|
+
provider: t,
|
|
787
|
+
env: this.ctx.env
|
|
788
|
+
});
|
|
789
|
+
return this._txHash = p, this.emitProgress({
|
|
790
|
+
status: e.COMPLETED,
|
|
791
|
+
steps: { staking: i.COMPLETE }
|
|
792
|
+
}), this.emitCompleted(), { txHash: p };
|
|
793
|
+
}, e.COMPLETED);
|
|
794
|
+
}
|
|
795
|
+
get prepareSchema() {
|
|
796
|
+
return x({
|
|
797
|
+
amount: L
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
function kt(n, a) {
|
|
802
|
+
return new Mt(n, a);
|
|
803
|
+
}
|
|
804
|
+
const Ht = I(m.LBTC, [r.prod]), Ft = I(m.LBTC, [
|
|
805
|
+
r.testnet,
|
|
806
|
+
r.stage,
|
|
807
|
+
r.dev,
|
|
808
|
+
r.ibc
|
|
809
|
+
]), Yt = j(
|
|
810
|
+
[m.LBTC, m.BTCb],
|
|
811
|
+
[r.prod]
|
|
812
|
+
), Vt = j(
|
|
813
|
+
[m.LBTC, m.BTCb],
|
|
814
|
+
[r.testnet, r.stage, r.dev, r.ibc]
|
|
815
|
+
), qt = {
|
|
816
|
+
routes: [
|
|
817
|
+
// Production: EVM chains with LBTC → Bitcoin Mainnet
|
|
818
|
+
{
|
|
819
|
+
sourceChains: Ht,
|
|
820
|
+
destChain: _.BITCOIN_MAINNET,
|
|
821
|
+
envs: [r.prod]
|
|
822
|
+
},
|
|
823
|
+
// Testnet: EVM chains with LBTC → Bitcoin Signet
|
|
824
|
+
{
|
|
825
|
+
sourceChains: Ft,
|
|
826
|
+
destChain: _.BITCOIN_SIGNET,
|
|
827
|
+
envs: [r.testnet, r.stage, r.dev, r.ibc]
|
|
828
|
+
}
|
|
829
|
+
],
|
|
830
|
+
recipientSchema: K
|
|
831
|
+
}, Gt = {
|
|
832
|
+
routes: [
|
|
833
|
+
// Production: Same-chain routes for chains with both LBTC and BTCb
|
|
834
|
+
...Yt.map((n) => ({
|
|
835
|
+
sourceChains: [n],
|
|
836
|
+
destChain: n,
|
|
837
|
+
envs: [r.prod]
|
|
838
|
+
})),
|
|
839
|
+
// Testnet: Same-chain routes
|
|
840
|
+
...Vt.map((n) => ({
|
|
841
|
+
sourceChains: [n],
|
|
842
|
+
destChain: n,
|
|
843
|
+
envs: [r.testnet, r.stage, r.dev, r.ibc]
|
|
844
|
+
}))
|
|
845
|
+
],
|
|
846
|
+
recipientSchema: Z
|
|
847
|
+
};
|
|
848
|
+
class Ut extends P {
|
|
849
|
+
constructor(t, s) {
|
|
850
|
+
super(e.IDLE);
|
|
851
|
+
u(this, "_amount");
|
|
852
|
+
u(this, "_recipient");
|
|
853
|
+
u(this, "_txHash");
|
|
854
|
+
u(this, "_feeAuth", F());
|
|
855
|
+
this.ctx = t, this.params = s;
|
|
856
|
+
}
|
|
857
|
+
get amount() {
|
|
858
|
+
return this._amount;
|
|
859
|
+
}
|
|
860
|
+
get recipient() {
|
|
861
|
+
return this._recipient;
|
|
862
|
+
}
|
|
863
|
+
get txHash() {
|
|
864
|
+
return this._txHash;
|
|
865
|
+
}
|
|
866
|
+
/** Fee authorization state (for UI display) */
|
|
867
|
+
get feeAuth() {
|
|
868
|
+
return this._feeAuth;
|
|
869
|
+
}
|
|
870
|
+
/** Whether output is BTC.b (requires fee auth on unsubsidized chains) */
|
|
871
|
+
get isBtcbOutput() {
|
|
872
|
+
return this.params.assetOut === m.BTCb;
|
|
873
|
+
}
|
|
874
|
+
async prepare(t) {
|
|
875
|
+
return this.assertStatus(e.IDLE, "prepare"), this.act(async () => {
|
|
876
|
+
const s = S(this.prepareSchema, t, {
|
|
877
|
+
destChain: this.params.destChain
|
|
878
|
+
});
|
|
879
|
+
this._amount = s.amount, this._recipient = s.recipient;
|
|
880
|
+
const o = E(this.params.sourceChain);
|
|
881
|
+
if (this.isBtcbOutput) {
|
|
882
|
+
const d = await this.ctx.getProvider("evm");
|
|
883
|
+
if (!d)
|
|
884
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
885
|
+
const v = (await d.request({
|
|
886
|
+
method: "eth_accounts"
|
|
887
|
+
}))[0], h = await k(
|
|
888
|
+
o,
|
|
889
|
+
v,
|
|
890
|
+
this.ctx.env,
|
|
891
|
+
l.BTCb
|
|
892
|
+
);
|
|
893
|
+
if (this._feeAuth = {
|
|
894
|
+
requiresAuth: h.requiresAuth,
|
|
895
|
+
isAuthorized: h.hasValidSignature,
|
|
896
|
+
feeInSatoshis: h.feeInSatoshis,
|
|
897
|
+
feeFormatted: h.feeFormatted,
|
|
898
|
+
expirationDate: h.expirationDate
|
|
899
|
+
}, h.requiresAuth && !h.hasValidSignature) {
|
|
900
|
+
this.emitProgress({
|
|
901
|
+
status: e.NEEDS_FEE_AUTHORIZATION,
|
|
902
|
+
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
903
|
+
});
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
this.emitProgress({
|
|
908
|
+
status: e.READY,
|
|
909
|
+
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
910
|
+
});
|
|
911
|
+
}, this._feeAuth.requiresAuth && !this._feeAuth.isAuthorized ? e.NEEDS_FEE_AUTHORIZATION : e.READY);
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Authorize the network fee
|
|
915
|
+
*
|
|
916
|
+
* Must be called when status is NEEDS_FEE_AUTHORIZATION.
|
|
917
|
+
* Signs the fee authorization and stores it on the server.
|
|
918
|
+
*/
|
|
919
|
+
async authorizeFee() {
|
|
920
|
+
if (this.assertStatus(e.NEEDS_FEE_AUTHORIZATION, "authorizeFee"), !this._feeAuth.feeInSatoshis)
|
|
921
|
+
throw c.missingParameter("feeInSatoshis");
|
|
922
|
+
return this.act(async () => {
|
|
923
|
+
const t = E(this.params.sourceChain), s = await this.ctx.getProvider("evm");
|
|
924
|
+
if (!s)
|
|
925
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
926
|
+
const d = (await s.request({
|
|
927
|
+
method: "eth_accounts"
|
|
928
|
+
}))[0];
|
|
929
|
+
await H({
|
|
930
|
+
chainId: t,
|
|
931
|
+
account: d,
|
|
932
|
+
feeInSatoshis: this._feeAuth.feeInSatoshis,
|
|
933
|
+
provider: s,
|
|
934
|
+
env: this.ctx.env,
|
|
935
|
+
token: l.BTCb
|
|
936
|
+
}), this._feeAuth.isAuthorized = !0, this.emitProgress({
|
|
937
|
+
status: e.READY,
|
|
938
|
+
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
939
|
+
});
|
|
940
|
+
}, e.READY);
|
|
941
|
+
}
|
|
942
|
+
async execute() {
|
|
943
|
+
return this.assertStatus(e.READY, "execute"), this.act(async () => {
|
|
944
|
+
const t = await this.ctx.getProvider("evm");
|
|
945
|
+
if (!t)
|
|
946
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
947
|
+
const o = (await t.request({
|
|
948
|
+
method: "eth_accounts"
|
|
949
|
+
}))[0];
|
|
950
|
+
if (!o)
|
|
951
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
952
|
+
const d = E(this.params.sourceChain), p = this.params.assetOut === m.BTCb;
|
|
953
|
+
this.emitProgress({
|
|
954
|
+
status: e.READY,
|
|
955
|
+
steps: { burning: i.PENDING, releasing: i.IDLE }
|
|
956
|
+
});
|
|
957
|
+
const v = await z({
|
|
958
|
+
provider: t,
|
|
959
|
+
account: p ? this._recipient : o,
|
|
960
|
+
amount: this._amount,
|
|
961
|
+
btcAddress: p ? void 0 : this._recipient,
|
|
962
|
+
chainId: d,
|
|
963
|
+
env: this.ctx.env,
|
|
964
|
+
tokenIn: l.LBTC,
|
|
965
|
+
tokenOut: p ? l.BTCb : void 0
|
|
966
|
+
});
|
|
967
|
+
return this._txHash = v, this.emitProgress({
|
|
968
|
+
status: e.COMPLETED,
|
|
969
|
+
steps: {
|
|
970
|
+
burning: i.COMPLETE,
|
|
971
|
+
releasing: p ? i.COMPLETE : i.PENDING
|
|
972
|
+
}
|
|
973
|
+
}), this.emitCompleted(), { txHash: v };
|
|
974
|
+
}, e.COMPLETED);
|
|
975
|
+
}
|
|
976
|
+
get prepareSchema() {
|
|
977
|
+
const t = this.params.assetOut === m.BTC ? qt : Gt;
|
|
978
|
+
return x({
|
|
979
|
+
amount: L,
|
|
980
|
+
recipient: t.recipientSchema
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
function zt(n, a) {
|
|
985
|
+
return new Ut(n, a);
|
|
986
|
+
}
|
|
987
|
+
const J = {
|
|
988
|
+
routes: [
|
|
989
|
+
// Veda - Ethereum, Base, BSC, Corn
|
|
990
|
+
{
|
|
991
|
+
sourceChains: [_.ETHEREUM, _.BASE, _.BSC, _.CORN],
|
|
992
|
+
protocols: [T.Veda],
|
|
993
|
+
envs: [r.prod]
|
|
994
|
+
}
|
|
995
|
+
]
|
|
996
|
+
};
|
|
997
|
+
class Wt extends P {
|
|
998
|
+
constructor(t, s) {
|
|
999
|
+
super(e.IDLE);
|
|
1000
|
+
u(this, "_txHash");
|
|
1001
|
+
u(this, "_account");
|
|
1002
|
+
u(this, "_chainId");
|
|
1003
|
+
this.ctx = t, this.params = s;
|
|
1004
|
+
}
|
|
1005
|
+
get txHash() {
|
|
1006
|
+
return this._txHash;
|
|
1007
|
+
}
|
|
1008
|
+
async prepare() {
|
|
1009
|
+
return this.assertStatus(e.IDLE, "prepare"), this.act(async () => {
|
|
1010
|
+
this.validateProtocol(this.params.protocol);
|
|
1011
|
+
const t = await this.ctx.getProvider("evm");
|
|
1012
|
+
if (!t)
|
|
1013
|
+
throw c.providerMissing(this.params.chain, "evm");
|
|
1014
|
+
const o = (await t.request({
|
|
1015
|
+
method: "eth_accounts"
|
|
1016
|
+
}))[0];
|
|
1017
|
+
if (!o)
|
|
1018
|
+
throw c.providerMissing(this.params.chain, "evm");
|
|
1019
|
+
if (this._account = o, this._chainId = E(this.params.chain), !X(this._chainId))
|
|
1020
|
+
throw new c(
|
|
1021
|
+
b.PROTOCOL_NOT_SUPPORTED,
|
|
1022
|
+
`Chain ${this.params.chain} does not support Veda vault withdrawals`,
|
|
1023
|
+
{ chain: this.params.chain, protocol: this.params.protocol }
|
|
1024
|
+
);
|
|
1025
|
+
this.emitProgress({
|
|
1026
|
+
status: e.READY,
|
|
1027
|
+
steps: { cancelling: i.PENDING }
|
|
1028
|
+
}), this.updateStatus(e.READY);
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
async execute() {
|
|
1032
|
+
return this.assertStatus(e.READY, "execute"), this.act(async () => {
|
|
1033
|
+
const t = await this.ctx.getProvider("evm");
|
|
1034
|
+
if (!t)
|
|
1035
|
+
throw c.providerMissing(this.params.chain, "evm");
|
|
1036
|
+
if (!this._account || !this._chainId)
|
|
1037
|
+
throw c.missingParameter("account or chainId");
|
|
1038
|
+
this.emitProgress({
|
|
1039
|
+
status: e.READY,
|
|
1040
|
+
steps: { cancelling: i.PENDING }
|
|
1041
|
+
});
|
|
1042
|
+
const s = await Et({
|
|
1043
|
+
vaultKey: D.Veda,
|
|
1044
|
+
account: this._account,
|
|
1045
|
+
chainId: this._chainId,
|
|
1046
|
+
provider: t,
|
|
1047
|
+
env: this.ctx.env
|
|
1048
|
+
});
|
|
1049
|
+
return this._txHash = s, this.emitProgress({
|
|
1050
|
+
status: e.COMPLETED,
|
|
1051
|
+
steps: { cancelling: i.COMPLETE }
|
|
1052
|
+
}), this.emitCompleted(), { txHash: s };
|
|
1053
|
+
}, e.COMPLETED);
|
|
1054
|
+
}
|
|
1055
|
+
validateProtocol(t) {
|
|
1056
|
+
if (!J.routes.some(
|
|
1057
|
+
(o) => o.protocols.includes(t) && o.envs.includes(this.ctx.env)
|
|
1058
|
+
))
|
|
1059
|
+
throw c.invalidParameter(
|
|
1060
|
+
"protocol",
|
|
1061
|
+
`Protocol ${t} is not supported for withdrawals in ${this.ctx.env} environment`
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
class $t extends P {
|
|
1066
|
+
constructor(t, s) {
|
|
1067
|
+
super(e.IDLE);
|
|
1068
|
+
u(this, "_amount");
|
|
1069
|
+
u(this, "_protocol");
|
|
1070
|
+
u(this, "_needsApproval", !1);
|
|
1071
|
+
u(this, "_txHash");
|
|
1072
|
+
u(this, "_account");
|
|
1073
|
+
u(this, "_chainId");
|
|
1074
|
+
this.ctx = t, this.params = s;
|
|
1075
|
+
}
|
|
1076
|
+
get amount() {
|
|
1077
|
+
return this._amount;
|
|
1078
|
+
}
|
|
1079
|
+
get protocol() {
|
|
1080
|
+
return this._protocol;
|
|
1081
|
+
}
|
|
1082
|
+
get needsApproval() {
|
|
1083
|
+
return this._needsApproval;
|
|
1084
|
+
}
|
|
1085
|
+
get txHash() {
|
|
1086
|
+
return this._txHash;
|
|
1087
|
+
}
|
|
1088
|
+
async prepare(t) {
|
|
1089
|
+
return this.assertStatus(e.IDLE, "prepare"), this.act(async () => {
|
|
1090
|
+
const s = S(this.prepareSchema, t);
|
|
1091
|
+
this._amount = s.amount, this._protocol = this.params.protocol, this.validateProtocol(this.params.protocol);
|
|
1092
|
+
const o = await this.ctx.getProvider("evm");
|
|
1093
|
+
if (!o)
|
|
1094
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
1095
|
+
const p = (await o.request({
|
|
1096
|
+
method: "eth_accounts"
|
|
1097
|
+
}))[0];
|
|
1098
|
+
if (!p)
|
|
1099
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
1100
|
+
if (this._account = p, this._chainId = E(this.params.sourceChain), !X(this._chainId))
|
|
1101
|
+
throw new c(
|
|
1102
|
+
b.PROTOCOL_NOT_SUPPORTED,
|
|
1103
|
+
`Chain ${this.params.sourceChain} does not support Veda vault withdrawals`,
|
|
1104
|
+
{ chain: this.params.sourceChain, protocol: this._protocol }
|
|
1105
|
+
);
|
|
1106
|
+
const v = B[D.Veda], h = O({ chainId: this._chainId }), A = await h.readContract({
|
|
1107
|
+
address: v.lensContract.address,
|
|
1108
|
+
abi: v.lensContract.abi,
|
|
1109
|
+
functionName: "balanceOf",
|
|
1110
|
+
args: [p, v.vaultContract.address]
|
|
1111
|
+
}), C = q(String(A), v.decimals), f = new w(s.amount);
|
|
1112
|
+
if (f.isGreaterThan(C))
|
|
1113
|
+
throw new c(
|
|
1114
|
+
b.INSUFFICIENT_SHARES,
|
|
1115
|
+
`Insufficient vault shares. Requested: ${f.toFixed()}, Available: ${C.toFixed()}`,
|
|
1116
|
+
{ requested: f.toFixed(), available: C.toFixed() }
|
|
1117
|
+
);
|
|
1118
|
+
const N = await h.readContract({
|
|
1119
|
+
address: v.vaultContract.address,
|
|
1120
|
+
abi: v.vaultContract.abi,
|
|
1121
|
+
functionName: "allowance",
|
|
1122
|
+
args: [p, v.withdrawQueueContracts[this._chainId].address]
|
|
1123
|
+
}), R = q(String(N), v.decimals);
|
|
1124
|
+
this._needsApproval = f.isGreaterThan(R), this._needsApproval ? (this.emitProgress({
|
|
1125
|
+
status: e.NEEDS_APPROVAL,
|
|
1126
|
+
steps: { approval: i.PENDING, queueing: i.IDLE }
|
|
1127
|
+
}), this.updateStatus(e.NEEDS_APPROVAL)) : (this.emitProgress({
|
|
1128
|
+
status: e.READY,
|
|
1129
|
+
steps: { approval: i.COMPLETE, queueing: i.PENDING }
|
|
1130
|
+
}), this.updateStatus(e.READY));
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
async approve() {
|
|
1134
|
+
return this.assertStatus(e.NEEDS_APPROVAL, "approve"), this.act(async () => {
|
|
1135
|
+
if (!this._account || !this._chainId || !this._amount)
|
|
1136
|
+
throw c.missingParameter("account, chainId, or amount");
|
|
1137
|
+
const t = await this.ctx.getProvider("evm");
|
|
1138
|
+
if (!t)
|
|
1139
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
1140
|
+
const s = B[D.Veda], o = new w(this._amount), d = Q(y(o, s.decimals)), p = O({ chainId: this._chainId }), v = W({
|
|
1141
|
+
provider: t,
|
|
1142
|
+
chainId: this._chainId
|
|
1143
|
+
}), h = this._chainId, { request: A } = await p.simulateContract({
|
|
1144
|
+
account: this._account,
|
|
1145
|
+
chain: $[this._chainId],
|
|
1146
|
+
address: s.vaultContract.address,
|
|
1147
|
+
abi: s.vaultContract.abi,
|
|
1148
|
+
functionName: "approve",
|
|
1149
|
+
args: [s.withdrawQueueContracts[h].address, d]
|
|
1150
|
+
});
|
|
1151
|
+
await v.writeContract(A), this._needsApproval = !1, this.emitProgress({
|
|
1152
|
+
status: e.READY,
|
|
1153
|
+
steps: { approval: i.COMPLETE, queueing: i.PENDING }
|
|
1154
|
+
});
|
|
1155
|
+
}, e.READY);
|
|
1156
|
+
}
|
|
1157
|
+
async execute() {
|
|
1158
|
+
return this.assertStatus(e.READY, "execute"), this.act(async () => {
|
|
1159
|
+
const t = await this.ctx.getProvider("evm");
|
|
1160
|
+
if (!t)
|
|
1161
|
+
throw c.providerMissing(this.params.sourceChain, "evm");
|
|
1162
|
+
if (!this._account || !this._chainId || !this._amount)
|
|
1163
|
+
throw c.missingParameter("account, chainId, or amount");
|
|
1164
|
+
this.emitProgress({
|
|
1165
|
+
status: e.READY,
|
|
1166
|
+
steps: { approval: i.COMPLETE, queueing: i.PENDING }
|
|
1167
|
+
});
|
|
1168
|
+
const s = await _t({
|
|
1169
|
+
amount: this._amount,
|
|
1170
|
+
approve: !1,
|
|
1171
|
+
vaultKey: D.Veda,
|
|
1172
|
+
account: this._account,
|
|
1173
|
+
chainId: this._chainId,
|
|
1174
|
+
provider: t,
|
|
1175
|
+
env: this.ctx.env
|
|
1176
|
+
});
|
|
1177
|
+
return this._txHash = s, this.emitProgress({
|
|
1178
|
+
status: e.COMPLETED,
|
|
1179
|
+
steps: { approval: i.COMPLETE, queueing: i.COMPLETE }
|
|
1180
|
+
}), this.emitCompleted(), { txHash: s };
|
|
1181
|
+
}, e.COMPLETED);
|
|
1182
|
+
}
|
|
1183
|
+
get prepareSchema() {
|
|
1184
|
+
return x({
|
|
1185
|
+
amount: L
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
validateProtocol(t) {
|
|
1189
|
+
if (!J.routes.some(
|
|
1190
|
+
(o) => o.protocols.includes(t) && o.envs.includes(this.ctx.env)
|
|
1191
|
+
))
|
|
1192
|
+
throw c.invalidParameter(
|
|
1193
|
+
"protocol",
|
|
1194
|
+
`Protocol ${t} is not supported for withdrawals in ${this.ctx.env} environment`
|
|
1195
|
+
);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
function Zt(n, a) {
|
|
1199
|
+
return new $t(n, a);
|
|
1200
|
+
}
|
|
1201
|
+
function Kt(n, a) {
|
|
1202
|
+
return new Wt(n, a);
|
|
1203
|
+
}
|
|
1204
|
+
class jt {
|
|
1205
|
+
constructor(a) {
|
|
1206
|
+
u(this, "ctx");
|
|
1207
|
+
this.ctx = pt(a);
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Stake BTC.b to receive LBTC
|
|
1211
|
+
*
|
|
1212
|
+
* Converts wrapped BTC (BTC.b) to LBTC via the Asset Router.
|
|
1213
|
+
* Currently supported on Avalanche.
|
|
1214
|
+
*
|
|
1215
|
+
* @example
|
|
1216
|
+
* ```typescript
|
|
1217
|
+
* const stake = evm.stake({
|
|
1218
|
+
* assetIn: AssetId.BTCb,
|
|
1219
|
+
* assetOut: AssetId.LBTC,
|
|
1220
|
+
* sourceChain: Chain.AVALANCHE,
|
|
1221
|
+
* destChain: Chain.AVALANCHE,
|
|
1222
|
+
* });
|
|
1223
|
+
* ```
|
|
1224
|
+
*/
|
|
1225
|
+
stake(a) {
|
|
1226
|
+
return kt(this.ctx, a);
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Unstake LBTC to BTC or BTC.b
|
|
1230
|
+
*
|
|
1231
|
+
* - LBTC → BTC: Cross-chain to Bitcoin mainnet/signet
|
|
1232
|
+
* - LBTC → BTC.b: Same-chain wrapped BTC on EVM
|
|
1233
|
+
*
|
|
1234
|
+
* @example
|
|
1235
|
+
* ```typescript
|
|
1236
|
+
* const unstake = evm.unstake({
|
|
1237
|
+
* assetIn: AssetId.LBTC,
|
|
1238
|
+
* assetOut: AssetId.BTC,
|
|
1239
|
+
* sourceChain: Chain.ETHEREUM,
|
|
1240
|
+
* destChain: Chain.BITCOIN_MAINNET,
|
|
1241
|
+
* });
|
|
1242
|
+
* ```
|
|
1243
|
+
*/
|
|
1244
|
+
unstake(a) {
|
|
1245
|
+
return zt(this.ctx, a);
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Deposit wrapped BTC to get LBTC
|
|
1249
|
+
*
|
|
1250
|
+
* Deposits WBTC or BTCb to receive LBTC.
|
|
1251
|
+
*
|
|
1252
|
+
* @example
|
|
1253
|
+
* ```typescript
|
|
1254
|
+
* const deposit = evm.deposit({
|
|
1255
|
+
* assetIn: AssetId.WBTC,
|
|
1256
|
+
* assetOut: AssetId.LBTC,
|
|
1257
|
+
* sourceChain: Chain.ETHEREUM,
|
|
1258
|
+
* destChain: Chain.ETHEREUM,
|
|
1259
|
+
* });
|
|
1260
|
+
* ```
|
|
1261
|
+
*/
|
|
1262
|
+
deposit(a) {
|
|
1263
|
+
return xt(this.ctx, a);
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Deploy L-Assets to DeFi protocols
|
|
1267
|
+
*
|
|
1268
|
+
* Currently supports Veda and Silo protocols.
|
|
1269
|
+
*
|
|
1270
|
+
* @example
|
|
1271
|
+
* ```typescript
|
|
1272
|
+
* const deploy = evm.deploy({
|
|
1273
|
+
* asset: AssetId.LBTC,
|
|
1274
|
+
* sourceChain: Chain.ETHEREUM,
|
|
1275
|
+
* protocol: DeployProtocol.Veda,
|
|
1276
|
+
* recipient: '0x...',
|
|
1277
|
+
* });
|
|
1278
|
+
* ```
|
|
1279
|
+
*/
|
|
1280
|
+
deploy(a) {
|
|
1281
|
+
return It(this.ctx, a);
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Withdraw vault shares from DeFi protocols
|
|
1285
|
+
*
|
|
1286
|
+
* Queues a withdrawal request from DeFi protocols (e.g., Veda vault).
|
|
1287
|
+
* After the withdrawal is queued, it will be processed within the
|
|
1288
|
+
* protocol's withdrawal window.
|
|
1289
|
+
*
|
|
1290
|
+
* @example
|
|
1291
|
+
* ```typescript
|
|
1292
|
+
* const withdraw = evm.withdraw({
|
|
1293
|
+
* protocol: DeployProtocol.Veda,
|
|
1294
|
+
* sourceChain: Chain.ETHEREUM,
|
|
1295
|
+
* recipient: '0x...',
|
|
1296
|
+
* });
|
|
1297
|
+
* await withdraw.prepare({ amount: '0.1' });
|
|
1298
|
+
* if (withdraw.needsApproval) await withdraw.approve();
|
|
1299
|
+
* await withdraw.execute();
|
|
1300
|
+
* ```
|
|
1301
|
+
*/
|
|
1302
|
+
withdraw(a) {
|
|
1303
|
+
return Zt(this.ctx, a);
|
|
1304
|
+
}
|
|
1305
|
+
/**
|
|
1306
|
+
* Cancel a pending withdrawal from DeFi protocols
|
|
1307
|
+
*
|
|
1308
|
+
* Cancels a previously queued withdrawal request.
|
|
1309
|
+
*
|
|
1310
|
+
* @example
|
|
1311
|
+
* ```typescript
|
|
1312
|
+
* const cancelWithdraw = evm.cancelWithdraw({
|
|
1313
|
+
* protocol: DeployProtocol.Veda,
|
|
1314
|
+
* chain: Chain.ETHEREUM,
|
|
1315
|
+
* });
|
|
1316
|
+
* await cancelWithdraw.prepare();
|
|
1317
|
+
* await cancelWithdraw.execute();
|
|
1318
|
+
* ```
|
|
1319
|
+
*/
|
|
1320
|
+
cancelWithdraw(a) {
|
|
1321
|
+
return Kt(this.ctx, a);
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Redeem LBTC to BTC.b (same-chain unwrap)
|
|
1325
|
+
*
|
|
1326
|
+
* Converts LBTC to BTC.b on the same EVM chain.
|
|
1327
|
+
* For cross-chain BTC redemption, use unstake() with destChain set to Bitcoin.
|
|
1328
|
+
*
|
|
1329
|
+
* @example
|
|
1330
|
+
* ```typescript
|
|
1331
|
+
* const redeem = evm.redeem({
|
|
1332
|
+
* assetIn: AssetId.LBTC,
|
|
1333
|
+
* assetOut: AssetId.BTCb,
|
|
1334
|
+
* sourceChain: Chain.AVALANCHE,
|
|
1335
|
+
* });
|
|
1336
|
+
* ```
|
|
1337
|
+
*/
|
|
1338
|
+
redeem(a) {
|
|
1339
|
+
return Rt(this.ctx, a);
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
function pe(n) {
|
|
1343
|
+
return new jt(n);
|
|
1344
|
+
}
|
|
1345
|
+
export {
|
|
1346
|
+
jt as E,
|
|
1347
|
+
ue as a,
|
|
1348
|
+
g as b,
|
|
1349
|
+
pe as e
|
|
1350
|
+
};
|
|
1351
|
+
//# sourceMappingURL=EvmActions-MW5mNmqs.js.map
|