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