@lombard.finance/sdk 4.7.1 → 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 +91 -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.cjs +1 -1
- package/dist/api.js +5 -5
- package/dist/bridge.cjs +1 -1
- package/dist/bridge.js +1 -1
- package/dist/btc.cjs +1 -1
- package/dist/btc.js +2 -2
- package/dist/chains/btc/actions/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-BczTnzRn.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-W-0-383w.js → ReferralsClient-BRa26dYS.js} +4 -4
- package/dist/chunks/ReferralsClient-BRa26dYS.js.map +1 -0
- package/dist/chunks/{ReferralsClient-D8dHEk_X.cjs → ReferralsClient-o-3AUm7s.cjs} +2 -2
- package/dist/chunks/ReferralsClient-o-3AUm7s.cjs.map +1 -0
- package/dist/chunks/{approveLBTC-BMC4cZEk.cjs → approveLBTC-BBl3KcT2.cjs} +2 -2
- package/dist/chunks/{approveLBTC-BMC4cZEk.cjs.map → approveLBTC-BBl3KcT2.cjs.map} +1 -1
- package/dist/chunks/{approveLBTC-BkdT1N3V.js → approveLBTC-DnCt6ZZF.js} +3 -3
- package/dist/chunks/{approveLBTC-BkdT1N3V.js.map → approveLBTC-DnCt6ZZF.js.map} +1 -1
- package/dist/chunks/{blockchain-identifier-BLPnwbIN.js → blockchain-identifier-BkASqCgZ.js} +2 -2
- package/dist/chunks/blockchain-identifier-BkASqCgZ.js.map +1 -0
- package/dist/chunks/{blockchain-identifier-Bp-LTIdG.cjs → blockchain-identifier-DWfC3Es2.cjs} +2 -2
- package/dist/chunks/blockchain-identifier-DWfC3Es2.cjs.map +1 -0
- package/dist/chunks/{bridge-DbB23m2a.js → bridge-DV4fOcHe.js} +4 -4
- package/dist/chunks/bridge-DV4fOcHe.js.map +1 -0
- package/dist/chunks/{bridge-7Eq_Jmi2.cjs → bridge-DZp5x4Yb.cjs} +2 -2
- package/dist/chunks/bridge-DZp5x4Yb.cjs.map +1 -0
- package/dist/chunks/{config-ow9X5H0c.cjs → config-BfX8lrdO.cjs} +2 -2
- package/dist/chunks/config-BfX8lrdO.cjs.map +1 -0
- package/dist/chunks/{config-C8BfN_9P.js → config-wnjPtnjd.js} +46 -53
- package/dist/chunks/config-wnjPtnjd.js.map +1 -0
- package/dist/chunks/{defi-registry-B8V6dRVB.cjs → defi-registry-CyMKVT3z.cjs} +2 -2
- package/dist/chunks/defi-registry-CyMKVT3z.cjs.map +1 -0
- package/dist/chunks/{defi-registry-CD8EUcNu.js → defi-registry-DULXbu3D.js} +9 -9
- package/dist/chunks/defi-registry-DULXbu3D.js.map +1 -0
- package/dist/chunks/{depositStatus-BJA7tNqc.cjs → depositStatus-B9P1YXEU.cjs} +2 -2
- package/dist/chunks/depositStatus-B9P1YXEU.cjs.map +1 -0
- package/dist/chunks/{depositStatus-HosfExLl.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-BlzP_SCT.js → events-DU2wYlt_.js} +189 -191
- package/dist/chunks/events-DU2wYlt_.js.map +1 -0
- package/dist/chunks/{get-exchange-ratio-Bl6pt546.js → get-exchange-ratio-BvPUfcIQ.js} +2 -2
- package/dist/chunks/{get-exchange-ratio-Bl6pt546.js.map → get-exchange-ratio-BvPUfcIQ.js.map} +1 -1
- package/dist/chunks/{get-exchange-ratio-t1PW8I6_.cjs → get-exchange-ratio-DGztGO7i.cjs} +2 -2
- package/dist/chunks/{get-exchange-ratio-t1PW8I6_.cjs.map → get-exchange-ratio-DGztGO7i.cjs.map} +1 -1
- package/dist/chunks/{get-positions-summary-DdZvBmCN.cjs → get-positions-summary-CC7BDtlY.cjs} +2 -2
- package/dist/chunks/get-positions-summary-CC7BDtlY.cjs.map +1 -0
- package/dist/chunks/{get-positions-summary-CaX2BCHp.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-CqlrwA0t.js → getUserStakeAndBakeSignature-BRhWFYyY.js} +4 -4
- package/dist/chunks/getUserStakeAndBakeSignature-BRhWFYyY.js.map +1 -0
- package/dist/chunks/{getUserStakeAndBakeSignature-BmY5j0OM.cjs → getUserStakeAndBakeSignature-VlC_GHmz.cjs} +2 -2
- package/dist/chunks/getUserStakeAndBakeSignature-VlC_GHmz.cjs.map +1 -0
- 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-BlyGFWnW.js → lbtc-addresses-ClXt-tuB.js} +2 -2
- package/dist/chunks/{lbtc-addresses-BlyGFWnW.js.map → lbtc-addresses-ClXt-tuB.js.map} +1 -1
- package/dist/chunks/{lbtc-addresses-DjsipX5Q.cjs → lbtc-addresses-D3jG1VUC.cjs} +2 -2
- package/dist/chunks/{lbtc-addresses-DjsipX5Q.cjs.map → lbtc-addresses-D3jG1VUC.cjs.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-BJIXJNIC.cjs → statusConstants-B-7VEYgO.cjs} +2 -2
- package/dist/chunks/statusConstants-B-7VEYgO.cjs.map +1 -0
- package/dist/chunks/{statusConstants-BQna5LGH.js → statusConstants-C3JHNUTC.js} +15 -17
- package/dist/chunks/statusConstants-C3JHNUTC.js.map +1 -0
- package/dist/chunks/{storeNetworkFeeSignature-tprCigR1.js → storeNetworkFeeSignature-CY_Z-Wtn.js} +2 -2
- package/dist/chunks/{storeNetworkFeeSignature-tprCigR1.js.map → storeNetworkFeeSignature-CY_Z-Wtn.js.map} +1 -1
- package/dist/chunks/{storeNetworkFeeSignature-CLm8I2pf.cjs → storeNetworkFeeSignature-DJgBfZp7.cjs} +2 -2
- package/dist/chunks/{storeNetworkFeeSignature-CLm8I2pf.cjs.map → storeNetworkFeeSignature-DJgBfZp7.cjs.map} +1 -1
- package/dist/chunks/token-addresses-C7H9E4qz.cjs +2 -0
- package/dist/chunks/token-addresses-C7H9E4qz.cjs.map +1 -0
- package/dist/chunks/{token-addresses-Ddar0FyS.js → token-addresses-DVnRPyu4.js} +16 -14
- package/dist/chunks/token-addresses-DVnRPyu4.js.map +1 -0
- package/dist/chunks/{tokens-HhVpKe3K.js → tokens-Btl3GXbc.js} +3 -3
- package/dist/chunks/tokens-Btl3GXbc.js.map +1 -0
- package/dist/chunks/{tokens-CBsz6l_2.cjs → tokens-DEYY7W7O.cjs} +2 -2
- package/dist/chunks/tokens-DEYY7W7O.cjs.map +1 -0
- 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-Bg8OsAMV.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 +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.cjs +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-BczTnzRn.js.map +0 -1
- package/dist/chunks/BtcActions-PyJhuiZN.cjs +0 -2
- package/dist/chunks/BtcActions-PyJhuiZN.cjs.map +0 -1
- package/dist/chunks/EvmActions-D3RAK9_Z.cjs +0 -2
- package/dist/chunks/EvmActions-D3RAK9_Z.cjs.map +0 -1
- package/dist/chunks/EvmActions-DSKThOAy.js +0 -1341
- package/dist/chunks/EvmActions-DSKThOAy.js.map +0 -1
- package/dist/chunks/ReferralsClient-D8dHEk_X.cjs.map +0 -1
- package/dist/chunks/ReferralsClient-W-0-383w.js.map +0 -1
- package/dist/chunks/blockchain-identifier-BLPnwbIN.js.map +0 -1
- package/dist/chunks/blockchain-identifier-Bp-LTIdG.cjs.map +0 -1
- package/dist/chunks/bridge-7Eq_Jmi2.cjs.map +0 -1
- package/dist/chunks/bridge-DbB23m2a.js.map +0 -1
- package/dist/chunks/config-C8BfN_9P.js.map +0 -1
- package/dist/chunks/config-ow9X5H0c.cjs.map +0 -1
- package/dist/chunks/defi-registry-B8V6dRVB.cjs.map +0 -1
- package/dist/chunks/defi-registry-CD8EUcNu.js.map +0 -1
- package/dist/chunks/depositStatus-BJA7tNqc.cjs.map +0 -1
- package/dist/chunks/depositStatus-HosfExLl.js.map +0 -1
- package/dist/chunks/events-BlzP_SCT.js.map +0 -1
- package/dist/chunks/events-DNehj45M.cjs +0 -2
- package/dist/chunks/events-DNehj45M.cjs.map +0 -1
- package/dist/chunks/get-positions-summary-CaX2BCHp.js.map +0 -1
- package/dist/chunks/get-positions-summary-DdZvBmCN.cjs.map +0 -1
- package/dist/chunks/get-vault-tvl-CihHEkqK.js +0 -226
- package/dist/chunks/get-vault-tvl-CihHEkqK.js.map +0 -1
- package/dist/chunks/get-vault-tvl-DZ-xzehy.cjs +0 -2
- package/dist/chunks/get-vault-tvl-DZ-xzehy.cjs.map +0 -1
- package/dist/chunks/get-vault-withdrawals-DLwFMQEB.cjs +0 -2
- package/dist/chunks/get-vault-withdrawals-DLwFMQEB.cjs.map +0 -1
- package/dist/chunks/get-vault-withdrawals-QJOdxB5Z.js +0 -161
- package/dist/chunks/get-vault-withdrawals-QJOdxB5Z.js.map +0 -1
- package/dist/chunks/getUserStakeAndBakeSignature-BmY5j0OM.cjs.map +0 -1
- package/dist/chunks/getUserStakeAndBakeSignature-CqlrwA0t.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-BJIXJNIC.cjs.map +0 -1
- package/dist/chunks/statusConstants-BQna5LGH.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-Ddar0FyS.js.map +0 -1
- package/dist/chunks/token-addresses-DvY-Mw7b.cjs +0 -2
- package/dist/chunks/token-addresses-DvY-Mw7b.cjs.map +0 -1
- package/dist/chunks/tokens-CBsz6l_2.cjs.map +0 -1
- package/dist/chunks/tokens-HhVpKe3K.js.map +0 -1
- package/dist/chunks/unstakeLBTC-Bg8OsAMV.js.map +0 -1
- package/dist/chunks/unstakeLBTC-BmHvDxBN.cjs +0 -2
- package/dist/chunks/unstakeLBTC-BmHvDxBN.cjs.map +0 -1
- package/dist/chunks/withdraw-Bkp5-2dG.cjs +0 -12
- package/dist/chunks/withdraw-Bkp5-2dG.cjs.map +0 -1
- package/dist/chunks/withdraw-kf8mYbYH.js +0 -209
- package/dist/chunks/withdraw-kf8mYbYH.js.map +0 -1
- package/dist/chunks/wrapToBtce-By2mh503.js +0 -298
- package/dist/chunks/wrapToBtce-By2mh503.js.map +0 -1
- package/dist/chunks/wrapToBtce-DDeIlv3d.cjs +0 -2
- package/dist/chunks/wrapToBtce-DDeIlv3d.cjs.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,15 +1,16 @@
|
|
|
1
|
-
import { determineEnv as
|
|
2
|
-
import { Token as d, AddressKind as
|
|
3
|
-
import { fromSatoshi as
|
|
4
|
-
import { p as
|
|
5
|
-
import { getContract as
|
|
6
|
-
import { DEFI_REGISTRY as
|
|
7
|
-
import
|
|
8
|
-
import { toUnix as
|
|
9
|
-
import { getExchangeRatio as
|
|
10
|
-
import { toBigInt as
|
|
11
|
-
import {
|
|
12
|
-
|
|
1
|
+
import { determineEnv as Y, makePublicClient as A, getTokenContractInfo as R, isUpgradedAbi as L, getErrorMessage as $, toBaseDenomination as F, getTokenInfo as O, fromBaseDenomination as W, UnsupportedTokenFlow as me, retrieveTokenProperties as ce } from "./tokens-Btl3GXbc.js";
|
|
2
|
+
import { Token as d, AddressKind as S, makeWalletClient as x, CHAIN_ID_TO_VIEM_CHAIN_MAP as C, ChainId as K, isKatanaChain as G, isMonadChain as Re, isEthereumChain as Me, isStableChain as xe, isMegaethChain as De } from "./token-addresses-DVnRPyu4.js";
|
|
3
|
+
import { fromSatoshi as J } from "./satoshi-CSoJBXc6.js";
|
|
4
|
+
import { p as X, d as Ee } from "./index-CfcQ_g3t.js";
|
|
5
|
+
import { getContract as be, isAddress as Be, erc20Abi as j, createWalletClient as Ne, http as Se, isHex as ke, encodeFunctionData as _e, decodeFunctionData as pe, encodeAbiParameters as Pe, keccak256 as Te, zeroAddress as Ie, parseGwei as ae, maxUint256 as $e } from "viem";
|
|
6
|
+
import { DEFI_REGISTRY as Fe, DefiProtocols as Le, DefiProtocol as Q } from "./defi-registry-DULXbu3D.js";
|
|
7
|
+
import f from "bignumber.js";
|
|
8
|
+
import { toUnix as fe, now as we, DAY as ee, isProviderFlow as se, isSignerFlow as Oe } from "./parameters-CcpaKGU2.js";
|
|
9
|
+
import { getExchangeRatio as Ue } from "./get-exchange-ratio-BvPUfcIQ.js";
|
|
10
|
+
import { toBigInt as _ } from "./numbers-CclN2Ohk.js";
|
|
11
|
+
import { isBtceVaultChain as re, BTCE_VAULT as k, BTCE_VAULT_DECIMALS as Ve, isEarnChain as oe, EARN_VAULT as Z } from "./config-wnjPtnjd.js";
|
|
12
|
+
import { ensureHex as ye } from "./hex-BiCL4CPh.js";
|
|
13
|
+
const U = [
|
|
13
14
|
{
|
|
14
15
|
inputs: [],
|
|
15
16
|
stateMutability: "nonpayable",
|
|
@@ -1975,259 +1976,259 @@ const S = [
|
|
|
1975
1976
|
type: "function"
|
|
1976
1977
|
}
|
|
1977
1978
|
];
|
|
1978
|
-
async function
|
|
1979
|
-
return
|
|
1979
|
+
async function xt(e) {
|
|
1980
|
+
return We({ token: d.LBTC, ...e });
|
|
1980
1981
|
}
|
|
1981
|
-
async function
|
|
1982
|
-
return
|
|
1982
|
+
async function Dt(e) {
|
|
1983
|
+
return ge({ token: d.LBTC, ...e });
|
|
1983
1984
|
}
|
|
1984
|
-
async function
|
|
1985
|
+
async function We({
|
|
1985
1986
|
token: e,
|
|
1986
|
-
chainId:
|
|
1987
|
-
rpcUrl:
|
|
1987
|
+
chainId: a,
|
|
1988
|
+
rpcUrl: n,
|
|
1988
1989
|
env: t
|
|
1989
1990
|
}) {
|
|
1990
1991
|
if (![d.LBTC, d.BTCK, d.BTCb].includes(e))
|
|
1991
1992
|
throw new Error(`Unsupported token: ${e}`);
|
|
1992
|
-
const
|
|
1993
|
+
const r = t || Y(a), o = A({ chainId: a, rpcUrl: n, env: r }), i = await R(
|
|
1993
1994
|
e,
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
),
|
|
1998
|
-
let
|
|
1999
|
-
if (
|
|
2000
|
-
const
|
|
2001
|
-
abi:
|
|
1995
|
+
a,
|
|
1996
|
+
r,
|
|
1997
|
+
S.Adapter
|
|
1998
|
+
), u = i.abi;
|
|
1999
|
+
let s = 0n;
|
|
2000
|
+
if (L(u) || e === d.BTCb) {
|
|
2001
|
+
const p = await o.readContract({
|
|
2002
|
+
abi: u,
|
|
2002
2003
|
address: i.address,
|
|
2003
2004
|
functionName: "getAssetRouter"
|
|
2004
2005
|
}), y = {
|
|
2005
|
-
abi:
|
|
2006
|
-
address:
|
|
2006
|
+
abi: U,
|
|
2007
|
+
address: p
|
|
2007
2008
|
};
|
|
2008
|
-
|
|
2009
|
+
s = await o.readContract({
|
|
2009
2010
|
abi: y.abi,
|
|
2010
2011
|
address: y.address,
|
|
2011
2012
|
functionName: "maxMintCommission",
|
|
2012
2013
|
args: [i.address]
|
|
2013
2014
|
});
|
|
2014
2015
|
} else
|
|
2015
|
-
|
|
2016
|
+
s = await o.readContract({
|
|
2016
2017
|
abi: i.abi,
|
|
2017
2018
|
address: i.address,
|
|
2018
2019
|
functionName: "getMintFee"
|
|
2019
2020
|
});
|
|
2020
|
-
return
|
|
2021
|
+
return J(String(s));
|
|
2021
2022
|
}
|
|
2022
|
-
async function
|
|
2023
|
+
async function ge({
|
|
2023
2024
|
token: e,
|
|
2024
|
-
chainId:
|
|
2025
|
-
rpcUrl:
|
|
2025
|
+
chainId: a,
|
|
2026
|
+
rpcUrl: n,
|
|
2026
2027
|
env: t
|
|
2027
2028
|
}) {
|
|
2028
2029
|
if (![d.LBTC, d.BTCK, d.BTCb].includes(e))
|
|
2029
2030
|
throw new Error(`Unsupported token: ${e}`);
|
|
2030
|
-
const
|
|
2031
|
+
const r = t || Y(a), o = A({ chainId: a, rpcUrl: n, env: r }), i = await R(
|
|
2031
2032
|
e,
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2033
|
+
a,
|
|
2034
|
+
r,
|
|
2035
|
+
S.Adapter
|
|
2035
2036
|
);
|
|
2036
|
-
let
|
|
2037
|
-
if (
|
|
2038
|
-
const
|
|
2037
|
+
let u = 0n;
|
|
2038
|
+
if (L(i.abi) || e === d.BTCb) {
|
|
2039
|
+
const s = await o.readContract({
|
|
2039
2040
|
abi: i.abi,
|
|
2040
2041
|
address: i.address,
|
|
2041
2042
|
functionName: "getAssetRouter"
|
|
2042
|
-
}),
|
|
2043
|
-
abi:
|
|
2044
|
-
address:
|
|
2045
|
-
}, y = await
|
|
2046
|
-
abi:
|
|
2047
|
-
address:
|
|
2043
|
+
}), p = {
|
|
2044
|
+
abi: U,
|
|
2045
|
+
address: s
|
|
2046
|
+
}, y = await o.readContract({
|
|
2047
|
+
abi: p.abi,
|
|
2048
|
+
address: p.address,
|
|
2048
2049
|
functionName: "toNativeCommission",
|
|
2049
2050
|
args: [i.address]
|
|
2050
2051
|
}), [
|
|
2051
2052
|
m
|
|
2052
2053
|
/* redeemForBtcMinAmountValue, isRedeemEnabled */
|
|
2053
|
-
] = await
|
|
2054
|
-
abi:
|
|
2055
|
-
address:
|
|
2054
|
+
] = await o.readContract({
|
|
2055
|
+
abi: p.abi,
|
|
2056
|
+
address: p.address,
|
|
2056
2057
|
functionName: "tokenConfig",
|
|
2057
2058
|
args: [i.address]
|
|
2058
2059
|
});
|
|
2059
|
-
|
|
2060
|
+
u = y + m;
|
|
2060
2061
|
} else
|
|
2061
|
-
|
|
2062
|
+
u = await o.readContract({
|
|
2062
2063
|
abi: i.abi,
|
|
2063
2064
|
address: i.address,
|
|
2064
2065
|
functionName: "getBurnCommission"
|
|
2065
2066
|
});
|
|
2066
|
-
return
|
|
2067
|
+
return J(String(u));
|
|
2067
2068
|
}
|
|
2068
|
-
async function
|
|
2069
|
+
async function Ge({
|
|
2069
2070
|
token: e,
|
|
2070
|
-
chainId:
|
|
2071
|
-
rpcUrl:
|
|
2071
|
+
chainId: a,
|
|
2072
|
+
rpcUrl: n,
|
|
2072
2073
|
env: t
|
|
2073
2074
|
}) {
|
|
2074
2075
|
if (![d.LBTC, d.BTCK, d.BTCb].includes(e))
|
|
2075
2076
|
throw new Error(`Unsupported token: ${e}`);
|
|
2076
|
-
const
|
|
2077
|
+
const r = t || Y(a), o = A({ chainId: a, rpcUrl: n, env: r }), i = await R(
|
|
2077
2078
|
e,
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2079
|
+
a,
|
|
2080
|
+
r,
|
|
2081
|
+
S.Adapter
|
|
2081
2082
|
);
|
|
2082
|
-
let
|
|
2083
|
-
if (
|
|
2084
|
-
const
|
|
2083
|
+
let u = 0n;
|
|
2084
|
+
if (L(i.abi) || e === d.BTCb) {
|
|
2085
|
+
const s = await o.readContract({
|
|
2085
2086
|
abi: i.abi,
|
|
2086
2087
|
address: i.address,
|
|
2087
2088
|
functionName: "getAssetRouter"
|
|
2088
|
-
}),
|
|
2089
|
-
abi:
|
|
2090
|
-
address:
|
|
2091
|
-
}, [, y] = await
|
|
2092
|
-
abi:
|
|
2093
|
-
address:
|
|
2089
|
+
}), p = {
|
|
2090
|
+
abi: U,
|
|
2091
|
+
address: s
|
|
2092
|
+
}, [, y] = await o.readContract({
|
|
2093
|
+
abi: p.abi,
|
|
2094
|
+
address: p.address,
|
|
2094
2095
|
functionName: "tokenConfig",
|
|
2095
2096
|
args: [i.address]
|
|
2096
2097
|
});
|
|
2097
|
-
|
|
2098
|
+
u = y;
|
|
2098
2099
|
} else
|
|
2099
|
-
|
|
2100
|
-
return
|
|
2100
|
+
u = 2000n;
|
|
2101
|
+
return J(String(u));
|
|
2101
2102
|
}
|
|
2102
|
-
async function
|
|
2103
|
-
const [
|
|
2104
|
-
|
|
2105
|
-
|
|
2103
|
+
async function Et(e) {
|
|
2104
|
+
const [a, n] = await Promise.all([
|
|
2105
|
+
ge(e),
|
|
2106
|
+
Ge(e)
|
|
2106
2107
|
]);
|
|
2107
|
-
return
|
|
2108
|
+
return a.plus(n);
|
|
2108
2109
|
}
|
|
2109
|
-
class
|
|
2110
|
-
constructor(
|
|
2111
|
-
super(
|
|
2110
|
+
class H extends Error {
|
|
2111
|
+
constructor(a, n, t) {
|
|
2112
|
+
super(n), this.code = a, this.context = t, this.name = "StakeAndBakeValidationError";
|
|
2112
2113
|
}
|
|
2113
2114
|
}
|
|
2114
|
-
function
|
|
2115
|
-
const
|
|
2116
|
-
if (!
|
|
2117
|
-
throw new
|
|
2115
|
+
function Ae(e, a, n, t) {
|
|
2116
|
+
const r = Fe[e];
|
|
2117
|
+
if (!r)
|
|
2118
|
+
throw new H(
|
|
2118
2119
|
"UNSUPPORTED_VAULT",
|
|
2119
2120
|
`Vault ${e} not found in DeFi registry`,
|
|
2120
2121
|
{ protocol: e }
|
|
2121
2122
|
);
|
|
2122
|
-
const
|
|
2123
|
-
if (!
|
|
2124
|
-
throw new
|
|
2123
|
+
const o = r[a];
|
|
2124
|
+
if (!o)
|
|
2125
|
+
throw new H(
|
|
2125
2126
|
"UNSUPPORTED_TOKEN",
|
|
2126
|
-
`Token ${
|
|
2127
|
-
{ protocol: e, token:
|
|
2127
|
+
`Token ${a} is not supported for stake and bake on vault ${e}. Supported tokens: ${Object.keys(r).join(", ")}`,
|
|
2128
|
+
{ protocol: e, token: a, supportedTokens: Object.keys(r) }
|
|
2128
2129
|
);
|
|
2129
|
-
const i =
|
|
2130
|
+
const i = o[t];
|
|
2130
2131
|
if (!i)
|
|
2131
|
-
throw new
|
|
2132
|
+
throw new H(
|
|
2132
2133
|
"UNSUPPORTED_ENV",
|
|
2133
|
-
`Environment ${t} is not supported for token ${
|
|
2134
|
-
{ protocol: e, token:
|
|
2134
|
+
`Environment ${t} is not supported for token ${a} on vault ${e}`,
|
|
2135
|
+
{ protocol: e, token: a, env: t }
|
|
2135
2136
|
);
|
|
2136
|
-
const
|
|
2137
|
-
if (!
|
|
2138
|
-
throw new
|
|
2137
|
+
const u = i[n];
|
|
2138
|
+
if (!u)
|
|
2139
|
+
throw new H(
|
|
2139
2140
|
"UNSUPPORTED_TOKEN_CHAIN",
|
|
2140
|
-
`Token ${
|
|
2141
|
+
`Token ${a} is not supported on chain ${n} for vault ${e} in ${t}. Supported chains: ${Object.keys(i).join(", ")}`,
|
|
2141
2142
|
{
|
|
2142
2143
|
protocol: e,
|
|
2143
|
-
token:
|
|
2144
|
-
chainId:
|
|
2144
|
+
token: a,
|
|
2145
|
+
chainId: n,
|
|
2145
2146
|
env: t,
|
|
2146
2147
|
supportedChains: Object.keys(i)
|
|
2147
2148
|
}
|
|
2148
2149
|
);
|
|
2149
2150
|
return {
|
|
2150
2151
|
protocol: e,
|
|
2151
|
-
token:
|
|
2152
|
+
token: a,
|
|
2152
2153
|
env: t,
|
|
2153
|
-
chainId:
|
|
2154
|
-
...
|
|
2154
|
+
chainId: n,
|
|
2155
|
+
...u
|
|
2155
2156
|
};
|
|
2156
2157
|
}
|
|
2157
|
-
const
|
|
2158
|
-
[
|
|
2159
|
-
[
|
|
2158
|
+
const He = {
|
|
2159
|
+
[Q.Veda]: d.LBTC,
|
|
2160
|
+
[Q.Silo]: d.BTCb
|
|
2160
2161
|
};
|
|
2161
|
-
async function
|
|
2162
|
-
protocol: e =
|
|
2163
|
-
token:
|
|
2164
|
-
chainId:
|
|
2165
|
-
env: t =
|
|
2166
|
-
rpcUrl:
|
|
2162
|
+
async function Bt({
|
|
2163
|
+
protocol: e = Q.Veda,
|
|
2164
|
+
token: a,
|
|
2165
|
+
chainId: n,
|
|
2166
|
+
env: t = X,
|
|
2167
|
+
rpcUrl: r
|
|
2167
2168
|
}) {
|
|
2168
|
-
const
|
|
2169
|
-
if (!
|
|
2169
|
+
const o = Le[e];
|
|
2170
|
+
if (!o)
|
|
2170
2171
|
throw new Error(`Unknown protocol: ${e}`);
|
|
2171
|
-
const i =
|
|
2172
|
+
const i = a ?? He[e];
|
|
2172
2173
|
try {
|
|
2173
|
-
const
|
|
2174
|
+
const s = Ae(
|
|
2174
2175
|
e,
|
|
2175
2176
|
i,
|
|
2176
|
-
|
|
2177
|
+
n,
|
|
2177
2178
|
t
|
|
2178
2179
|
).spenderContract;
|
|
2179
|
-
if (!
|
|
2180
|
+
if (!s)
|
|
2180
2181
|
throw new Error(
|
|
2181
|
-
`Could not retrieve the stake and bake contract for ${e} on chain ${
|
|
2182
|
+
`Could not retrieve the stake and bake contract for ${e} on chain ${n}.`
|
|
2182
2183
|
);
|
|
2183
|
-
const
|
|
2184
|
-
abi:
|
|
2185
|
-
address:
|
|
2186
|
-
client:
|
|
2184
|
+
const p = A({ chainId: n, rpcUrl: r }), m = await be({
|
|
2185
|
+
abi: s.abi,
|
|
2186
|
+
address: s.address,
|
|
2187
|
+
client: p
|
|
2187
2188
|
}).read.getStakeAndBakeFee();
|
|
2188
|
-
return
|
|
2189
|
-
} catch (
|
|
2190
|
-
const
|
|
2189
|
+
return J(String(m));
|
|
2190
|
+
} catch (u) {
|
|
2191
|
+
const s = $(u);
|
|
2191
2192
|
throw new Error(
|
|
2192
|
-
`Failed to get stake and bake fee for ${
|
|
2193
|
+
`Failed to get stake and bake fee for ${o.name}: ${s}`
|
|
2193
2194
|
);
|
|
2194
2195
|
}
|
|
2195
2196
|
}
|
|
2196
|
-
function
|
|
2197
|
+
function qe(e) {
|
|
2197
2198
|
return `destination chain id is ${e}`;
|
|
2198
2199
|
}
|
|
2199
|
-
async function
|
|
2200
|
+
async function Nt({
|
|
2200
2201
|
account: e,
|
|
2201
|
-
chainId:
|
|
2202
|
-
provider:
|
|
2202
|
+
chainId: a,
|
|
2203
|
+
provider: n
|
|
2203
2204
|
}) {
|
|
2204
|
-
const t =
|
|
2205
|
-
return await t.signMessage({ account: e, message:
|
|
2205
|
+
const t = x({ chainId: a, provider: n }), r = qe(a);
|
|
2206
|
+
return await t.signMessage({ account: e, message: r });
|
|
2206
2207
|
}
|
|
2207
|
-
async function
|
|
2208
|
+
async function St({
|
|
2208
2209
|
fee: e,
|
|
2209
|
-
expiry:
|
|
2210
|
-
account:
|
|
2210
|
+
expiry: a = fe(we() + ee),
|
|
2211
|
+
account: n,
|
|
2211
2212
|
chainId: t,
|
|
2212
|
-
provider:
|
|
2213
|
-
env:
|
|
2213
|
+
provider: r,
|
|
2214
|
+
env: o,
|
|
2214
2215
|
token: i = d.LBTC
|
|
2215
2216
|
}) {
|
|
2216
|
-
const
|
|
2217
|
+
const u = await R(i, t, o), s = x({
|
|
2217
2218
|
chainId: t,
|
|
2218
|
-
provider:
|
|
2219
|
-
}),
|
|
2220
|
-
account:
|
|
2219
|
+
provider: r
|
|
2220
|
+
}), p = {
|
|
2221
|
+
account: n,
|
|
2221
2222
|
domain: {
|
|
2222
2223
|
name: i === d.BTCb ? "Bitcoin" : "Lombard Staked Bitcoin",
|
|
2223
2224
|
version: "1",
|
|
2224
2225
|
chainId: t,
|
|
2225
|
-
verifyingContract:
|
|
2226
|
+
verifyingContract: u.address
|
|
2226
2227
|
},
|
|
2227
2228
|
message: {
|
|
2228
2229
|
chainId: t,
|
|
2229
|
-
fee: BigInt(
|
|
2230
|
-
expiry:
|
|
2230
|
+
fee: BigInt(f(e).toFixed()),
|
|
2231
|
+
expiry: a
|
|
2231
2232
|
},
|
|
2232
2233
|
primaryType: "feeApproval",
|
|
2233
2234
|
types: {
|
|
@@ -2245,45 +2246,45 @@ async function Ct({
|
|
|
2245
2246
|
}
|
|
2246
2247
|
};
|
|
2247
2248
|
return {
|
|
2248
|
-
signature: await
|
|
2249
|
+
signature: await s.signTypedData(p),
|
|
2249
2250
|
typedData: JSON.stringify(
|
|
2250
|
-
|
|
2251
|
-
(m,
|
|
2251
|
+
p,
|
|
2252
|
+
(m, c) => typeof c == "bigint" ? c.toString() : c
|
|
2252
2253
|
)
|
|
2253
2254
|
};
|
|
2254
2255
|
}
|
|
2255
|
-
async function
|
|
2256
|
+
async function ze({
|
|
2256
2257
|
owner: e,
|
|
2257
|
-
chainId:
|
|
2258
|
-
rpcUrl:
|
|
2259
|
-
env: t =
|
|
2258
|
+
chainId: a,
|
|
2259
|
+
rpcUrl: n,
|
|
2260
|
+
env: t = X
|
|
2260
2261
|
}) {
|
|
2261
|
-
const
|
|
2262
|
+
const r = t || Y(a), o = A({ chainId: a, rpcUrl: n }), i = await R(
|
|
2262
2263
|
d.LBTC,
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
),
|
|
2264
|
+
a,
|
|
2265
|
+
r
|
|
2266
|
+
), u = await o.readContract({
|
|
2266
2267
|
abi: i.abi,
|
|
2267
2268
|
address: i.address,
|
|
2268
2269
|
functionName: "nonces",
|
|
2269
2270
|
args: [e]
|
|
2270
2271
|
});
|
|
2271
|
-
return String(
|
|
2272
|
+
return String(u);
|
|
2272
2273
|
}
|
|
2273
|
-
const
|
|
2274
|
+
const Ke = [
|
|
2274
2275
|
{ name: "name", type: "string" },
|
|
2275
2276
|
{ name: "version", type: "string" },
|
|
2276
2277
|
{ name: "chainId", type: "uint256" },
|
|
2277
2278
|
{ name: "verifyingContract", type: "address" }
|
|
2278
|
-
],
|
|
2279
|
+
], Ce = [
|
|
2279
2280
|
{ name: "owner", type: "address" },
|
|
2280
2281
|
{ name: "spender", type: "address" },
|
|
2281
2282
|
{ name: "value", type: "uint256" },
|
|
2282
2283
|
{ name: "nonce", type: "uint256" },
|
|
2283
2284
|
{ name: "deadline", type: "uint256" }
|
|
2284
|
-
],
|
|
2285
|
-
function
|
|
2286
|
-
const
|
|
2285
|
+
], je = Ce;
|
|
2286
|
+
function Qe(e) {
|
|
2287
|
+
const a = e.mode === "permit" ? "Permit" : "Approve";
|
|
2287
2288
|
return {
|
|
2288
2289
|
account: e.account,
|
|
2289
2290
|
domain: {
|
|
@@ -2293,10 +2294,10 @@ function Ve(e) {
|
|
|
2293
2294
|
verifyingContract: e.verifyingContract
|
|
2294
2295
|
},
|
|
2295
2296
|
types: {
|
|
2296
|
-
EIP712Domain:
|
|
2297
|
-
[
|
|
2297
|
+
EIP712Domain: Ke,
|
|
2298
|
+
[a]: e.mode === "permit" ? Ce : je
|
|
2298
2299
|
},
|
|
2299
|
-
primaryType:
|
|
2300
|
+
primaryType: a,
|
|
2300
2301
|
message: {
|
|
2301
2302
|
owner: e.account,
|
|
2302
2303
|
spender: e.spender,
|
|
@@ -2306,147 +2307,252 @@ function Ve(e) {
|
|
|
2306
2307
|
}
|
|
2307
2308
|
};
|
|
2308
2309
|
}
|
|
2309
|
-
function
|
|
2310
|
+
function he(e) {
|
|
2310
2311
|
return JSON.stringify(
|
|
2311
2312
|
e,
|
|
2312
|
-
(
|
|
2313
|
+
(a, n) => typeof n == "bigint" ? n.toString() : n
|
|
2313
2314
|
);
|
|
2314
2315
|
}
|
|
2315
|
-
async function
|
|
2316
|
+
async function Ze(e) {
|
|
2316
2317
|
const {
|
|
2317
|
-
account:
|
|
2318
|
-
chainId:
|
|
2318
|
+
account: a,
|
|
2319
|
+
chainId: n,
|
|
2319
2320
|
provider: t,
|
|
2320
|
-
rpcUrl:
|
|
2321
|
-
tokenAddress:
|
|
2321
|
+
rpcUrl: r,
|
|
2322
|
+
tokenAddress: o,
|
|
2322
2323
|
tokenAbi: i,
|
|
2323
|
-
spenderAddress:
|
|
2324
|
-
typedData:
|
|
2325
|
-
requiredAmount:
|
|
2326
|
-
} = e, y =
|
|
2327
|
-
address:
|
|
2324
|
+
spenderAddress: u,
|
|
2325
|
+
typedData: s,
|
|
2326
|
+
requiredAmount: p
|
|
2327
|
+
} = e, y = A({ chainId: n, rpcUrl: r }), m = x({ chainId: n, provider: t }), c = await y.readContract({
|
|
2328
|
+
address: o,
|
|
2328
2329
|
abi: i,
|
|
2329
2330
|
functionName: "allowance",
|
|
2330
|
-
args: [
|
|
2331
|
+
args: [a, u]
|
|
2331
2332
|
});
|
|
2332
2333
|
let l;
|
|
2333
|
-
if (
|
|
2334
|
-
const
|
|
2335
|
-
address:
|
|
2334
|
+
if (c < p) {
|
|
2335
|
+
const b = await m.writeContract({
|
|
2336
|
+
address: o,
|
|
2336
2337
|
abi: i,
|
|
2337
2338
|
functionName: "approve",
|
|
2338
|
-
args: [
|
|
2339
|
-
account:
|
|
2339
|
+
args: [u, p],
|
|
2340
|
+
account: a,
|
|
2340
2341
|
chain: null
|
|
2341
2342
|
});
|
|
2342
|
-
if ((await y.waitForTransactionReceipt({ hash:
|
|
2343
|
+
if ((await y.waitForTransactionReceipt({ hash: b })).status !== "success")
|
|
2343
2344
|
throw new Error(
|
|
2344
|
-
`Approve transaction failed: ${
|
|
2345
|
+
`Approve transaction failed: ${b}. Please try again or contact support.`
|
|
2345
2346
|
);
|
|
2346
|
-
l =
|
|
2347
|
+
l = b;
|
|
2347
2348
|
}
|
|
2348
2349
|
return {
|
|
2349
2350
|
mode: "approve",
|
|
2350
2351
|
signature: "",
|
|
2351
|
-
typedData:
|
|
2352
|
+
typedData: he(s),
|
|
2352
2353
|
approvalTxHash: l
|
|
2353
2354
|
};
|
|
2354
2355
|
}
|
|
2355
|
-
async function
|
|
2356
|
-
const { chainId:
|
|
2356
|
+
async function Ye(e) {
|
|
2357
|
+
const { chainId: a, provider: n, typedData: t } = e;
|
|
2357
2358
|
return {
|
|
2358
2359
|
mode: "permit",
|
|
2359
|
-
signature: await
|
|
2360
|
-
typedData:
|
|
2360
|
+
signature: await x({ chainId: a, provider: n }).signTypedData(t),
|
|
2361
|
+
typedData: he(t)
|
|
2361
2362
|
};
|
|
2362
2363
|
}
|
|
2363
|
-
const
|
|
2364
|
-
async function
|
|
2365
|
-
var
|
|
2364
|
+
const Je = async (e, a, n) => !e || e === "BTC" || e === d.LBTC ? await R(d.LBTC, a, n) : await R(e, a, n, S.Token);
|
|
2365
|
+
async function Xe(e, a) {
|
|
2366
|
+
var n;
|
|
2366
2367
|
try {
|
|
2367
|
-
const
|
|
2368
|
-
return new
|
|
2368
|
+
const r = ((n = (await Ue({ env: a })).LBTC) == null ? void 0 : n.BTCTokenRatio) || new f(1);
|
|
2369
|
+
return new f(e).dividedBy(r);
|
|
2369
2370
|
} catch {
|
|
2370
2371
|
throw new Error("Failed to get exchange ratio for stake and bake");
|
|
2371
2372
|
}
|
|
2372
2373
|
}
|
|
2373
|
-
async function
|
|
2374
|
+
async function kt({
|
|
2374
2375
|
account: e,
|
|
2375
|
-
expiry:
|
|
2376
|
-
value:
|
|
2376
|
+
expiry: a = fe(we() + ee),
|
|
2377
|
+
value: n,
|
|
2377
2378
|
// TODO: Rename vaultKey to protocol
|
|
2378
|
-
vaultKey: t =
|
|
2379
|
-
token:
|
|
2380
|
-
chainId:
|
|
2379
|
+
vaultKey: t = Q.Veda,
|
|
2380
|
+
token: r = "BTC",
|
|
2381
|
+
chainId: o,
|
|
2381
2382
|
provider: i,
|
|
2382
|
-
rpcUrl:
|
|
2383
|
-
env:
|
|
2383
|
+
rpcUrl: u,
|
|
2384
|
+
env: s = X
|
|
2384
2385
|
}) {
|
|
2385
|
-
const
|
|
2386
|
-
mode:
|
|
2386
|
+
const p = Ae(t, r, o, s), y = p.spenderContract.address, m = p.amountStrategy === "btcToLbtc" ? await Xe(n, s) : new f(n), c = await Je(r, o, s), l = c.address, b = c.abi, T = p.approval.deadlineStrategy === "zero" ? 0n : BigInt(a), h = p.approval.nonceStrategy === "chain" ? BigInt(await ze({ owner: e, chainId: o, rpcUrl: u, env: s })) : 0n, w = Qe({
|
|
2387
|
+
mode: p.approval.mode,
|
|
2387
2388
|
account: e,
|
|
2388
|
-
chainId:
|
|
2389
|
+
chainId: o,
|
|
2389
2390
|
verifyingContract: l,
|
|
2390
|
-
domainName:
|
|
2391
|
-
domainVersion:
|
|
2391
|
+
domainName: p.approval.domainName,
|
|
2392
|
+
domainVersion: p.approval.domainVersion,
|
|
2392
2393
|
spender: y,
|
|
2393
|
-
value: BigInt(m.toFixed(0,
|
|
2394
|
+
value: BigInt(m.toFixed(0, f.ROUND_DOWN)),
|
|
2394
2395
|
nonce: h,
|
|
2395
|
-
deadline:
|
|
2396
|
+
deadline: T
|
|
2396
2397
|
});
|
|
2397
|
-
return
|
|
2398
|
+
return p.approval.mode === "approve" ? Ze({
|
|
2398
2399
|
account: e,
|
|
2399
|
-
chainId:
|
|
2400
|
+
chainId: o,
|
|
2400
2401
|
provider: i,
|
|
2401
|
-
rpcUrl:
|
|
2402
|
+
rpcUrl: u,
|
|
2402
2403
|
tokenAddress: l,
|
|
2403
|
-
tokenAbi:
|
|
2404
|
+
tokenAbi: b,
|
|
2404
2405
|
spenderAddress: y,
|
|
2405
|
-
typedData:
|
|
2406
|
-
requiredAmount: BigInt(m.toFixed(0,
|
|
2407
|
-
}) :
|
|
2406
|
+
typedData: w,
|
|
2407
|
+
requiredAmount: BigInt(m.toFixed(0, f.ROUND_DOWN))
|
|
2408
|
+
}) : Ye({ chainId: o, provider: i, typedData: w });
|
|
2408
2409
|
}
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2410
|
+
async function et({
|
|
2411
|
+
tokenAddress: e,
|
|
2412
|
+
amount: a,
|
|
2413
|
+
tokenDecimals: n,
|
|
2414
|
+
receiver: t,
|
|
2415
|
+
minimumMint: r = 0,
|
|
2416
|
+
account: o,
|
|
2417
|
+
chainId: i,
|
|
2418
|
+
provider: u,
|
|
2419
|
+
rpcUrl: s
|
|
2420
|
+
}) {
|
|
2421
|
+
if (!Be(e, { strict: !1 }))
|
|
2422
|
+
throw new Error(`Invalid token address: ${e}`);
|
|
2423
|
+
if (!re(i))
|
|
2424
|
+
throw new Error(
|
|
2425
|
+
`BTCe is not supported on chain ${i}. Supported chains: ${k.chains.join(", ")}.`
|
|
2426
|
+
);
|
|
2427
|
+
const p = f(a);
|
|
2428
|
+
if (!p.isGreaterThan(0))
|
|
2429
|
+
throw new Error(
|
|
2430
|
+
`Wrap amount must be greater than zero. Received: ${p.toFixed()}.`
|
|
2431
|
+
);
|
|
2432
|
+
const y = _(F(p, n)), m = _(
|
|
2433
|
+
F(f(r), Ve)
|
|
2434
|
+
), c = A({ chainId: i, rpcUrl: s }), l = x({ provider: u, chainId: i });
|
|
2435
|
+
try {
|
|
2436
|
+
const { request: b } = await c.simulateContract({
|
|
2437
|
+
account: o,
|
|
2438
|
+
chain: C[i],
|
|
2439
|
+
abi: k.abi,
|
|
2440
|
+
address: k.contracts[i],
|
|
2441
|
+
functionName: "deposit",
|
|
2442
|
+
args: [e, y, t ?? o, m]
|
|
2443
|
+
});
|
|
2444
|
+
return await l.writeContract(b);
|
|
2445
|
+
} catch (b) {
|
|
2446
|
+
const T = $(b);
|
|
2447
|
+
throw new Error(T);
|
|
2412
2448
|
}
|
|
2413
2449
|
}
|
|
2414
|
-
function
|
|
2450
|
+
async function _t({
|
|
2451
|
+
token: e = d.LBTC,
|
|
2452
|
+
amount: a,
|
|
2453
|
+
receiver: n,
|
|
2454
|
+
minimumMint: t = 0,
|
|
2455
|
+
approve: r = !0,
|
|
2456
|
+
account: o,
|
|
2457
|
+
chainId: i,
|
|
2458
|
+
provider: u,
|
|
2459
|
+
rpcUrl: s,
|
|
2460
|
+
env: p
|
|
2461
|
+
}) {
|
|
2462
|
+
if (!re(i))
|
|
2463
|
+
throw new Error(
|
|
2464
|
+
`BTCe is not supported on chain ${i}. Supported chains: ${k.chains.join(", ")}.`
|
|
2465
|
+
);
|
|
2466
|
+
const y = f(a);
|
|
2467
|
+
if (!y.isGreaterThan(0))
|
|
2468
|
+
throw new Error(
|
|
2469
|
+
`Deposit amount must be greater than zero. Received: ${y.toFixed()}.`
|
|
2470
|
+
);
|
|
2471
|
+
const m = await O(e, i, p, s);
|
|
2472
|
+
if (!m)
|
|
2473
|
+
throw new Error(
|
|
2474
|
+
`Could not resolve token info for ${e} on chain ${i}.`
|
|
2475
|
+
);
|
|
2476
|
+
const c = A({ chainId: i, rpcUrl: s }), l = x({ provider: u, chainId: i }), b = k.contracts[i], T = _(F(y, m.decimals));
|
|
2477
|
+
if (await c.readContract({
|
|
2478
|
+
address: m.address,
|
|
2479
|
+
abi: j,
|
|
2480
|
+
functionName: "allowance",
|
|
2481
|
+
args: [o, b]
|
|
2482
|
+
}) < T) {
|
|
2483
|
+
if (!r)
|
|
2484
|
+
throw new Error(
|
|
2485
|
+
`Deposit amount ${y.toFixed()} exceeds allowance for ${e} -> BTCe. Re-run with approve: true or pre-approve the BTCe contract.`
|
|
2486
|
+
);
|
|
2487
|
+
try {
|
|
2488
|
+
const { request: w } = await c.simulateContract({
|
|
2489
|
+
account: o,
|
|
2490
|
+
chain: C[i],
|
|
2491
|
+
address: m.address,
|
|
2492
|
+
abi: j,
|
|
2493
|
+
functionName: "approve",
|
|
2494
|
+
args: [b, T]
|
|
2495
|
+
}), D = await l.writeContract(w);
|
|
2496
|
+
await c.waitForTransactionReceipt({ hash: D });
|
|
2497
|
+
} catch (w) {
|
|
2498
|
+
throw new Error(
|
|
2499
|
+
`Approval of ${e} for BTCe failed: ${$(w)}`
|
|
2500
|
+
);
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
return et({
|
|
2504
|
+
tokenAddress: m.address,
|
|
2505
|
+
amount: y,
|
|
2506
|
+
tokenDecimals: m.decimals,
|
|
2507
|
+
receiver: n,
|
|
2508
|
+
minimumMint: t,
|
|
2509
|
+
account: o,
|
|
2510
|
+
chainId: i,
|
|
2511
|
+
provider: u,
|
|
2512
|
+
rpcUrl: s
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
class g extends Error {
|
|
2516
|
+
constructor(a, n, t) {
|
|
2517
|
+
super(n), this.code = a, this.context = t, this.name = "SignerError";
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
function ve(e, a = "transaction") {
|
|
2415
2521
|
if (!e.from)
|
|
2416
|
-
throw new
|
|
2522
|
+
throw new g(
|
|
2417
2523
|
"MISSING_FROM_ADDRESS",
|
|
2418
|
-
`Missing 'from' address for ${
|
|
2419
|
-
{ transaction: e, operation:
|
|
2524
|
+
`Missing 'from' address for ${a}`,
|
|
2525
|
+
{ transaction: e, operation: a }
|
|
2420
2526
|
);
|
|
2421
2527
|
if (!e.to)
|
|
2422
|
-
throw new
|
|
2528
|
+
throw new g(
|
|
2423
2529
|
"MISSING_TO_ADDRESS",
|
|
2424
|
-
`Missing 'to' address for ${
|
|
2425
|
-
{ transaction: e, operation:
|
|
2530
|
+
`Missing 'to' address for ${a}`,
|
|
2531
|
+
{ transaction: e, operation: a }
|
|
2426
2532
|
);
|
|
2427
|
-
if (e.data !== void 0 && !
|
|
2428
|
-
throw new
|
|
2533
|
+
if (e.data !== void 0 && !ke(e.data))
|
|
2534
|
+
throw new g(
|
|
2429
2535
|
"INVALID_DATA",
|
|
2430
|
-
`Transaction data must be valid hex string for ${
|
|
2431
|
-
{ transaction: e, operation:
|
|
2536
|
+
`Transaction data must be valid hex string for ${a}`,
|
|
2537
|
+
{ transaction: e, operation: a, data: e.data }
|
|
2432
2538
|
);
|
|
2433
2539
|
if (e.chainId && !/^0x[0-9a-fA-F]+$/.test(e.chainId))
|
|
2434
|
-
throw new
|
|
2540
|
+
throw new g(
|
|
2435
2541
|
"INVALID_CHAIN_ID",
|
|
2436
|
-
`Chain ID must be a hex string (e.g., "0x1") for ${
|
|
2437
|
-
{ transaction: e, operation:
|
|
2542
|
+
`Chain ID must be a hex string (e.g., "0x1") for ${a}`,
|
|
2543
|
+
{ transaction: e, operation: a, chainId: e.chainId }
|
|
2438
2544
|
);
|
|
2439
2545
|
}
|
|
2440
|
-
function
|
|
2441
|
-
const t =
|
|
2546
|
+
function tt(e, a, n) {
|
|
2547
|
+
const t = C[n];
|
|
2442
2548
|
if (!t)
|
|
2443
|
-
throw new
|
|
2549
|
+
throw new g(
|
|
2444
2550
|
"UNSUPPORTED_CHAIN",
|
|
2445
|
-
`Chain ID ${
|
|
2446
|
-
{ chainId:
|
|
2551
|
+
`Chain ID ${n} is not supported`,
|
|
2552
|
+
{ chainId: n, availableChains: Object.keys(C) }
|
|
2447
2553
|
);
|
|
2448
2554
|
return {
|
|
2449
|
-
address:
|
|
2555
|
+
address: a,
|
|
2450
2556
|
type: "local",
|
|
2451
2557
|
publicKey: "0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
2452
2558
|
source: "custom",
|
|
@@ -2454,34 +2560,34 @@ function ze(e, n, a) {
|
|
|
2454
2560
|
* Signs a transaction using the SignerAdapter.
|
|
2455
2561
|
* This is called by Viem's wallet client when executing transactions.
|
|
2456
2562
|
*/
|
|
2457
|
-
async signTransaction(
|
|
2563
|
+
async signTransaction(o) {
|
|
2458
2564
|
const i = {
|
|
2459
|
-
from:
|
|
2460
|
-
to:
|
|
2461
|
-
data:
|
|
2462
|
-
value:
|
|
2463
|
-
gas:
|
|
2464
|
-
maxFeePerGas:
|
|
2465
|
-
maxPriorityFeePerGas:
|
|
2466
|
-
chainId:
|
|
2467
|
-
nonce:
|
|
2565
|
+
from: a,
|
|
2566
|
+
to: o.to ?? void 0,
|
|
2567
|
+
data: o.data,
|
|
2568
|
+
value: o.value,
|
|
2569
|
+
gas: o.gas,
|
|
2570
|
+
maxFeePerGas: o.maxFeePerGas,
|
|
2571
|
+
maxPriorityFeePerGas: o.maxPriorityFeePerGas,
|
|
2572
|
+
chainId: o.chainId ? `0x${o.chainId.toString(16)}` : `0x${t.id.toString(16)}`,
|
|
2573
|
+
nonce: o.nonce
|
|
2468
2574
|
};
|
|
2469
|
-
|
|
2470
|
-
let
|
|
2471
|
-
if (await e.sign(i, async (
|
|
2472
|
-
throw new
|
|
2575
|
+
ve(i, "signTransaction");
|
|
2576
|
+
let u;
|
|
2577
|
+
if (await e.sign(i, async (s) => (u = s, s)), !u)
|
|
2578
|
+
throw new g(
|
|
2473
2579
|
"SIGNING_FAILED",
|
|
2474
2580
|
"Signer did not return a signed transaction",
|
|
2475
2581
|
{ transaction: i }
|
|
2476
2582
|
);
|
|
2477
|
-
return
|
|
2583
|
+
return u;
|
|
2478
2584
|
},
|
|
2479
2585
|
/**
|
|
2480
2586
|
* Signs a message (EIP-191).
|
|
2481
2587
|
* Not implemented as it's not needed for contract transactions.
|
|
2482
2588
|
*/
|
|
2483
2589
|
async signMessage() {
|
|
2484
|
-
throw new
|
|
2590
|
+
throw new g(
|
|
2485
2591
|
"NOT_IMPLEMENTED",
|
|
2486
2592
|
"Message signing is not supported by this adapter",
|
|
2487
2593
|
{ method: "signMessage" }
|
|
@@ -2492,7 +2598,7 @@ function ze(e, n, a) {
|
|
|
2492
2598
|
* Not implemented as it's not needed for contract transactions.
|
|
2493
2599
|
*/
|
|
2494
2600
|
async signTypedData() {
|
|
2495
|
-
throw new
|
|
2601
|
+
throw new g(
|
|
2496
2602
|
"NOT_IMPLEMENTED",
|
|
2497
2603
|
"Typed data signing is not supported by this adapter",
|
|
2498
2604
|
{ method: "signTypedData" }
|
|
@@ -2500,136 +2606,136 @@ function ze(e, n, a) {
|
|
|
2500
2606
|
}
|
|
2501
2607
|
};
|
|
2502
2608
|
}
|
|
2503
|
-
function
|
|
2504
|
-
const t =
|
|
2609
|
+
function Pt(e, a, n) {
|
|
2610
|
+
const t = C[n];
|
|
2505
2611
|
if (!t)
|
|
2506
|
-
throw new
|
|
2612
|
+
throw new g(
|
|
2507
2613
|
"UNSUPPORTED_CHAIN",
|
|
2508
|
-
`Chain ID ${
|
|
2509
|
-
{ chainId:
|
|
2614
|
+
`Chain ID ${n} is not supported`,
|
|
2615
|
+
{ chainId: n }
|
|
2510
2616
|
);
|
|
2511
|
-
const
|
|
2512
|
-
return
|
|
2513
|
-
account:
|
|
2617
|
+
const r = tt(e, a, n);
|
|
2618
|
+
return Ne({
|
|
2619
|
+
account: r,
|
|
2514
2620
|
chain: t,
|
|
2515
|
-
transport:
|
|
2621
|
+
transport: Se()
|
|
2516
2622
|
// Uses default RPC
|
|
2517
2623
|
});
|
|
2518
2624
|
}
|
|
2519
|
-
async function
|
|
2625
|
+
async function q({
|
|
2520
2626
|
params: e,
|
|
2521
|
-
publicClient:
|
|
2522
|
-
walletClient:
|
|
2627
|
+
publicClient: a,
|
|
2628
|
+
walletClient: n,
|
|
2523
2629
|
simulateArgs: t,
|
|
2524
|
-
operation:
|
|
2630
|
+
operation: r
|
|
2525
2631
|
}) {
|
|
2526
|
-
if (!
|
|
2527
|
-
throw new
|
|
2632
|
+
if (!se(e) && !Oe(e))
|
|
2633
|
+
throw new g(
|
|
2528
2634
|
"INVALID_PARAMETERS",
|
|
2529
2635
|
'Must provide either "provider" or "signer" in parameters',
|
|
2530
|
-
{ params: e, operation:
|
|
2636
|
+
{ params: e, operation: r }
|
|
2531
2637
|
);
|
|
2532
|
-
let
|
|
2638
|
+
let o;
|
|
2533
2639
|
try {
|
|
2534
|
-
|
|
2640
|
+
o = await a.simulateContract(
|
|
2535
2641
|
t
|
|
2536
2642
|
);
|
|
2537
|
-
} catch (
|
|
2538
|
-
throw new
|
|
2643
|
+
} catch (s) {
|
|
2644
|
+
throw new g(
|
|
2539
2645
|
"SIMULATION_FAILED",
|
|
2540
|
-
`Failed to simulate ${
|
|
2646
|
+
`Failed to simulate ${r} transaction: ${s instanceof Error ? s.message : "Unknown error"}`,
|
|
2541
2647
|
{
|
|
2542
|
-
operation:
|
|
2648
|
+
operation: r,
|
|
2543
2649
|
simulateArgs: t,
|
|
2544
|
-
error:
|
|
2650
|
+
error: s instanceof Error ? s.message : String(s)
|
|
2545
2651
|
}
|
|
2546
2652
|
);
|
|
2547
2653
|
}
|
|
2548
|
-
const { request: i } =
|
|
2654
|
+
const { request: i } = o;
|
|
2549
2655
|
if (!i.account)
|
|
2550
|
-
throw new
|
|
2656
|
+
throw new g(
|
|
2551
2657
|
"INVALID_SIMULATION",
|
|
2552
|
-
`Simulation succeeded but no account was set for ${
|
|
2553
|
-
{ operation:
|
|
2658
|
+
`Simulation succeeded but no account was set for ${r}`,
|
|
2659
|
+
{ operation: r, request: i }
|
|
2554
2660
|
);
|
|
2555
2661
|
if (!i.address)
|
|
2556
|
-
throw new
|
|
2662
|
+
throw new g(
|
|
2557
2663
|
"INVALID_SIMULATION",
|
|
2558
|
-
`Simulation succeeded but no target address was set for ${
|
|
2559
|
-
{ operation:
|
|
2664
|
+
`Simulation succeeded but no target address was set for ${r}`,
|
|
2665
|
+
{ operation: r, request: i }
|
|
2560
2666
|
);
|
|
2561
|
-
let
|
|
2562
|
-
if (
|
|
2563
|
-
if (!
|
|
2564
|
-
throw new
|
|
2667
|
+
let u;
|
|
2668
|
+
if (se(e)) {
|
|
2669
|
+
if (!n)
|
|
2670
|
+
throw new g(
|
|
2565
2671
|
"MISSING_WALLET_CLIENT",
|
|
2566
2672
|
"Provider flow requires a wallet client",
|
|
2567
|
-
{ operation:
|
|
2673
|
+
{ operation: r, params: e }
|
|
2568
2674
|
);
|
|
2569
2675
|
try {
|
|
2570
|
-
|
|
2571
|
-
} catch (
|
|
2572
|
-
throw new
|
|
2676
|
+
u = await n.writeContract(i);
|
|
2677
|
+
} catch (s) {
|
|
2678
|
+
throw new g(
|
|
2573
2679
|
"PROVIDER_TRANSACTION_FAILED",
|
|
2574
|
-
`Failed to execute ${
|
|
2680
|
+
`Failed to execute ${r} via provider: ${s instanceof Error ? s.message : "Unknown error"}`,
|
|
2575
2681
|
{
|
|
2576
|
-
operation:
|
|
2682
|
+
operation: r,
|
|
2577
2683
|
request: i,
|
|
2578
|
-
error:
|
|
2684
|
+
error: s instanceof Error ? s.message : String(s)
|
|
2579
2685
|
}
|
|
2580
2686
|
);
|
|
2581
2687
|
}
|
|
2582
2688
|
} else
|
|
2583
2689
|
try {
|
|
2584
|
-
const
|
|
2585
|
-
if (!
|
|
2586
|
-
throw new
|
|
2690
|
+
const s = C[e.chainId];
|
|
2691
|
+
if (!s)
|
|
2692
|
+
throw new g(
|
|
2587
2693
|
"UNSUPPORTED_CHAIN",
|
|
2588
2694
|
`Chain ${e.chainId} not supported`,
|
|
2589
2695
|
{ chainId: e.chainId }
|
|
2590
2696
|
);
|
|
2591
|
-
const
|
|
2697
|
+
const p = _e({
|
|
2592
2698
|
abi: t.abi,
|
|
2593
2699
|
functionName: t.functionName,
|
|
2594
2700
|
args: t.args
|
|
2595
2701
|
}), y = {
|
|
2596
2702
|
from: e.account,
|
|
2597
2703
|
to: i.address,
|
|
2598
|
-
data:
|
|
2704
|
+
data: p,
|
|
2599
2705
|
value: i.value,
|
|
2600
2706
|
gas: i.gas,
|
|
2601
2707
|
maxFeePerGas: i.maxFeePerGas,
|
|
2602
2708
|
maxPriorityFeePerGas: i.maxPriorityFeePerGas,
|
|
2603
|
-
chainId: `0x${
|
|
2709
|
+
chainId: `0x${s.id.toString(16)}`
|
|
2604
2710
|
};
|
|
2605
|
-
|
|
2711
|
+
ve(y, r), u = await e.signer.sign(y, async (m) => await a.sendRawTransaction({
|
|
2606
2712
|
serializedTransaction: m
|
|
2607
2713
|
}));
|
|
2608
|
-
} catch (
|
|
2609
|
-
throw new
|
|
2714
|
+
} catch (s) {
|
|
2715
|
+
throw new g(
|
|
2610
2716
|
"SIGNER_TRANSACTION_FAILED",
|
|
2611
|
-
`Failed to execute ${
|
|
2717
|
+
`Failed to execute ${r} via signer: ${s instanceof Error ? s.message : "Unknown error"}`,
|
|
2612
2718
|
{
|
|
2613
|
-
operation:
|
|
2719
|
+
operation: r,
|
|
2614
2720
|
request: i,
|
|
2615
|
-
error:
|
|
2721
|
+
error: s instanceof Error ? s.message : String(s)
|
|
2616
2722
|
}
|
|
2617
2723
|
);
|
|
2618
2724
|
}
|
|
2619
|
-
return { txHash:
|
|
2725
|
+
return { txHash: u, request: i };
|
|
2620
2726
|
}
|
|
2621
|
-
async function
|
|
2727
|
+
async function nt(e, a, n) {
|
|
2622
2728
|
try {
|
|
2623
2729
|
const t = await e.waitForTransactionReceipt({
|
|
2624
|
-
hash:
|
|
2730
|
+
hash: a
|
|
2625
2731
|
});
|
|
2626
2732
|
if (t.status === "reverted")
|
|
2627
|
-
throw new
|
|
2733
|
+
throw new g(
|
|
2628
2734
|
"TRANSACTION_REVERTED",
|
|
2629
|
-
`${
|
|
2735
|
+
`${n} transaction reverted`,
|
|
2630
2736
|
{
|
|
2631
|
-
operation:
|
|
2632
|
-
txHash:
|
|
2737
|
+
operation: n,
|
|
2738
|
+
txHash: a,
|
|
2633
2739
|
receipt: {
|
|
2634
2740
|
blockNumber: t.blockNumber,
|
|
2635
2741
|
gasUsed: t.gasUsed
|
|
@@ -2638,18 +2744,18 @@ async function je(e, n, a) {
|
|
|
2638
2744
|
);
|
|
2639
2745
|
return t;
|
|
2640
2746
|
} catch (t) {
|
|
2641
|
-
throw t instanceof
|
|
2747
|
+
throw t instanceof g ? t : new g(
|
|
2642
2748
|
"RECEIPT_WAIT_FAILED",
|
|
2643
|
-
`Failed to wait for ${
|
|
2749
|
+
`Failed to wait for ${n} transaction receipt: ${t instanceof Error ? t.message : "Unknown error"}`,
|
|
2644
2750
|
{
|
|
2645
|
-
operation:
|
|
2646
|
-
txHash:
|
|
2751
|
+
operation: n,
|
|
2752
|
+
txHash: a,
|
|
2647
2753
|
error: t instanceof Error ? t.message : String(t)
|
|
2648
2754
|
}
|
|
2649
2755
|
);
|
|
2650
2756
|
}
|
|
2651
2757
|
}
|
|
2652
|
-
const
|
|
2758
|
+
const de = "0xe288fb4a", le = "0x155b6b13", at = {
|
|
2653
2759
|
type: "function",
|
|
2654
2760
|
name: "MessageV1",
|
|
2655
2761
|
inputs: [
|
|
@@ -2660,7 +2766,7 @@ const J = "0xe288fb4a", Q = "0x155b6b13", qe = {
|
|
|
2660
2766
|
{ name: "msgDestinationCaller", type: "bytes32" },
|
|
2661
2767
|
{ name: "msgBody", type: "bytes" }
|
|
2662
2768
|
]
|
|
2663
|
-
},
|
|
2769
|
+
}, st = {
|
|
2664
2770
|
type: "function",
|
|
2665
2771
|
name: "mint",
|
|
2666
2772
|
inputs: [
|
|
@@ -2669,53 +2775,53 @@ const J = "0xe288fb4a", Q = "0x155b6b13", qe = {
|
|
|
2669
2775
|
{ name: "amount", type: "uint256" }
|
|
2670
2776
|
]
|
|
2671
2777
|
};
|
|
2672
|
-
function
|
|
2778
|
+
function it(e) {
|
|
2673
2779
|
if (!e.startsWith("0x"))
|
|
2674
2780
|
throw new Error("Payload must be 0x-prefixed hex");
|
|
2675
|
-
const
|
|
2676
|
-
if (
|
|
2781
|
+
const a = e.slice(0, 10);
|
|
2782
|
+
if (a.toLowerCase() !== de.toLowerCase())
|
|
2677
2783
|
throw new Error(
|
|
2678
|
-
`Invalid GMP selector: expected ${
|
|
2784
|
+
`Invalid GMP selector: expected ${de}, got ${a}`
|
|
2679
2785
|
);
|
|
2680
|
-
const
|
|
2681
|
-
abi: [
|
|
2786
|
+
const n = pe({
|
|
2787
|
+
abi: [at],
|
|
2682
2788
|
data: e
|
|
2683
2789
|
});
|
|
2684
|
-
if (!
|
|
2790
|
+
if (!n.args)
|
|
2685
2791
|
throw new Error("Failed to decode GMP payload: args is undefined");
|
|
2686
|
-
const t =
|
|
2687
|
-
if (typeof
|
|
2792
|
+
const t = n.args[0], r = n.args[1], o = n.args[2], i = n.args[3], u = n.args[4], s = n.args[5];
|
|
2793
|
+
if (typeof s != "string" || !s.startsWith("0x"))
|
|
2688
2794
|
throw new Error("msgBody is not valid hex");
|
|
2689
|
-
const
|
|
2690
|
-
if (
|
|
2795
|
+
const p = s.slice(0, 10);
|
|
2796
|
+
if (p.toLowerCase() !== le.toLowerCase())
|
|
2691
2797
|
throw new Error(
|
|
2692
|
-
`Invalid mint selector in body: expected ${
|
|
2798
|
+
`Invalid mint selector in body: expected ${le}, got ${p}`
|
|
2693
2799
|
);
|
|
2694
|
-
const y =
|
|
2695
|
-
abi: [
|
|
2696
|
-
data:
|
|
2800
|
+
const y = pe({
|
|
2801
|
+
abi: [st],
|
|
2802
|
+
data: s
|
|
2697
2803
|
});
|
|
2698
2804
|
if (!y.args)
|
|
2699
2805
|
throw new Error("Failed to decode mint body: args is undefined");
|
|
2700
|
-
const m = y.args[0],
|
|
2806
|
+
const m = y.args[0], c = y.args[1], l = y.args[2];
|
|
2701
2807
|
return {
|
|
2702
|
-
selector:
|
|
2808
|
+
selector: a,
|
|
2703
2809
|
msgPath: t,
|
|
2704
|
-
msgNonce:
|
|
2705
|
-
msgSender:
|
|
2810
|
+
msgNonce: r,
|
|
2811
|
+
msgSender: o,
|
|
2706
2812
|
msgRecipient: i,
|
|
2707
|
-
msgDestinationCaller:
|
|
2708
|
-
rawBody:
|
|
2813
|
+
msgDestinationCaller: u,
|
|
2814
|
+
rawBody: s,
|
|
2709
2815
|
mint: {
|
|
2710
|
-
selector:
|
|
2816
|
+
selector: p,
|
|
2711
2817
|
toToken: m,
|
|
2712
|
-
recipient:
|
|
2818
|
+
recipient: c,
|
|
2713
2819
|
amount: l
|
|
2714
2820
|
}
|
|
2715
2821
|
};
|
|
2716
2822
|
}
|
|
2717
|
-
function
|
|
2718
|
-
const { msgNonce:
|
|
2823
|
+
function rt(e, a) {
|
|
2824
|
+
const { msgNonce: n, mint: t } = e, r = Pe(
|
|
2719
2825
|
[
|
|
2720
2826
|
{ name: "nonce", type: "uint256" },
|
|
2721
2827
|
{ name: "chainId", type: "uint256" },
|
|
@@ -2724,9 +2830,9 @@ function Je(e, n) {
|
|
|
2724
2830
|
{ name: "amount", type: "uint256" }
|
|
2725
2831
|
],
|
|
2726
2832
|
[
|
|
2727
|
-
BigInt(a),
|
|
2728
|
-
// self.nonce
|
|
2729
2833
|
BigInt(n),
|
|
2834
|
+
// self.nonce
|
|
2835
|
+
BigInt(a),
|
|
2730
2836
|
// block.chainid
|
|
2731
2837
|
t.recipient,
|
|
2732
2838
|
// self.recipient
|
|
@@ -2736,9 +2842,9 @@ function Je(e, n) {
|
|
|
2736
2842
|
// self.amount
|
|
2737
2843
|
]
|
|
2738
2844
|
);
|
|
2739
|
-
return
|
|
2845
|
+
return Te(r);
|
|
2740
2846
|
}
|
|
2741
|
-
const
|
|
2847
|
+
const ot = [
|
|
2742
2848
|
{
|
|
2743
2849
|
inputs: [
|
|
2744
2850
|
{ internalType: "address", name: "aDefaultAdmin", type: "address" },
|
|
@@ -3390,172 +3496,172 @@ const Qe = [
|
|
|
3390
3496
|
stateMutability: "view",
|
|
3391
3497
|
type: "function"
|
|
3392
3498
|
}
|
|
3393
|
-
], Xe = /* @__PURE__ */ JSON.parse('[{"inputs":[{"internalType":"address","name":"aDefaultAdmin","type":"address"},{"internalType":"address","name":"aPauser","type":"address"},{"internalType":"address","name":"aDepositReporter","type":"address"},{"internalType":"address","name":"aWithdrawalValidator","type":"address"},{"internalType":"uint256","name":"aMaxDeposits","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"uint48","name":"schedule","type":"uint48"}],"name":"AccessControlEnforcedDefaultAdminDelay","type":"error"},{"inputs":[],"name":"AccessControlEnforcedDefaultAdminRules","type":"error"},{"inputs":[{"internalType":"address","name":"defaultAdmin","type":"address"}],"name":"AccessControlInvalidDefaultAdmin","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"bytes32","name":"depositID","type":"bytes32"}],"name":"AlreadyReported","type":"error"},{"inputs":[{"internalType":"bytes32","name":"depositID","type":"bytes32"},{"internalType":"uint256","name":"withdrawalAmount","type":"uint256"}],"name":"AlreadyWithdrawn","type":"error"},{"inputs":[],"name":"BadDepositReport","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[],"name":"SameValidationThreshold","type":"error"},{"inputs":[{"internalType":"bytes32","name":"depositID","type":"bytes32"},{"internalType":"uint256","name":"withdrawalAmount","type":"uint256"}],"name":"WithdrawalFailedValidation","type":"error"},{"anonymous":false,"inputs":[],"name":"DefaultAdminDelayChangeCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint48","name":"newDelay","type":"uint48"},{"indexed":false,"internalType":"uint48","name":"effectSchedule","type":"uint48"}],"name":"DefaultAdminDelayChangeScheduled","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminTransferCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"},{"indexed":false,"internalType":"uint48","name":"acceptSchedule","type":"uint48"}],"name":"DefaultAdminTransferScheduled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"reportId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"numDeposits","type":"uint256"}],"name":"DepositsReported","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"numDeposits","type":"uint256"}],"name":"MaxDepositsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newThreshold","type":"uint256"}],"name":"UpdateValidateThreshold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"depositID","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"withdrawalAmount","type":"uint256"}],"name":"WithdrawalNotValidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"depositID","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"withdrawalAmount","type":"uint256"}],"name":"WithdrawalValidated","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSIT_REPORTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VALIDATION_GUARDIAN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAWAL_VALIDATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"beginDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"}],"name":"changeDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelay","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelayIncreaseWait","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"depositID","type":"bytes32"}],"name":"depositHistory","outputs":[{"internalType":"enum Bascule.DepositState","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdmin","outputs":[{"internalType":"address","name":"newAdmin","type":"address"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdminDelay","outputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"reportId","type":"bytes32"},{"internalType":"bytes32[]","name":"depositIDs","type":"bytes32[]"}],"name":"reportDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollbackDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"aMaxDeposits","type":"uint256"}],"name":"setMaxDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newThreshold","type":"uint256"}],"name":"updateValidateThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"validateThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"depositID","type":"bytes32"},{"internalType":"uint256","name":"withdrawalAmount","type":"uint256"}],"name":"validateWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"}]');
|
|
3394
|
-
var
|
|
3395
|
-
async function
|
|
3499
|
+
], ut = /* @__PURE__ */ JSON.parse('[{"inputs":[{"internalType":"address","name":"aDefaultAdmin","type":"address"},{"internalType":"address","name":"aPauser","type":"address"},{"internalType":"address","name":"aDepositReporter","type":"address"},{"internalType":"address","name":"aWithdrawalValidator","type":"address"},{"internalType":"uint256","name":"aMaxDeposits","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"uint48","name":"schedule","type":"uint48"}],"name":"AccessControlEnforcedDefaultAdminDelay","type":"error"},{"inputs":[],"name":"AccessControlEnforcedDefaultAdminRules","type":"error"},{"inputs":[{"internalType":"address","name":"defaultAdmin","type":"address"}],"name":"AccessControlInvalidDefaultAdmin","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"bytes32","name":"depositID","type":"bytes32"}],"name":"AlreadyReported","type":"error"},{"inputs":[{"internalType":"bytes32","name":"depositID","type":"bytes32"},{"internalType":"uint256","name":"withdrawalAmount","type":"uint256"}],"name":"AlreadyWithdrawn","type":"error"},{"inputs":[],"name":"BadDepositReport","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[],"name":"SameValidationThreshold","type":"error"},{"inputs":[{"internalType":"bytes32","name":"depositID","type":"bytes32"},{"internalType":"uint256","name":"withdrawalAmount","type":"uint256"}],"name":"WithdrawalFailedValidation","type":"error"},{"anonymous":false,"inputs":[],"name":"DefaultAdminDelayChangeCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint48","name":"newDelay","type":"uint48"},{"indexed":false,"internalType":"uint48","name":"effectSchedule","type":"uint48"}],"name":"DefaultAdminDelayChangeScheduled","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminTransferCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"},{"indexed":false,"internalType":"uint48","name":"acceptSchedule","type":"uint48"}],"name":"DefaultAdminTransferScheduled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"reportId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"numDeposits","type":"uint256"}],"name":"DepositsReported","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"numDeposits","type":"uint256"}],"name":"MaxDepositsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldThreshold","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newThreshold","type":"uint256"}],"name":"UpdateValidateThreshold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"depositID","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"withdrawalAmount","type":"uint256"}],"name":"WithdrawalNotValidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"depositID","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"withdrawalAmount","type":"uint256"}],"name":"WithdrawalValidated","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEPOSIT_REPORTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VALIDATION_GUARDIAN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAWAL_VALIDATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"beginDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"}],"name":"changeDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelay","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelayIncreaseWait","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"depositID","type":"bytes32"}],"name":"depositHistory","outputs":[{"internalType":"enum Bascule.DepositState","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdmin","outputs":[{"internalType":"address","name":"newAdmin","type":"address"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdminDelay","outputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"reportId","type":"bytes32"},{"internalType":"bytes32[]","name":"depositIDs","type":"bytes32[]"}],"name":"reportDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollbackDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"aMaxDeposits","type":"uint256"}],"name":"setMaxDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newThreshold","type":"uint256"}],"name":"updateValidateThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"validateThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"depositID","type":"bytes32"},{"internalType":"uint256","name":"withdrawalAmount","type":"uint256"}],"name":"validateWithdrawal","outputs":[],"stateMutability":"nonpayable","type":"function"}]');
|
|
3500
|
+
var z = /* @__PURE__ */ ((e) => (e[e.UNREPORTED = 0] = "UNREPORTED", e[e.REPORTED = 1] = "REPORTED", e[e.WITHDRAWN = 2] = "WITHDRAWN", e))(z || {});
|
|
3501
|
+
async function pt({
|
|
3396
3502
|
deposit: e,
|
|
3397
|
-
rawPayload:
|
|
3398
|
-
provider:
|
|
3503
|
+
rawPayload: a,
|
|
3504
|
+
provider: n,
|
|
3399
3505
|
chainId: t,
|
|
3400
|
-
rpcUrl:
|
|
3401
|
-
env:
|
|
3506
|
+
rpcUrl: r,
|
|
3507
|
+
env: o = X,
|
|
3402
3508
|
token: i = d.LBTC
|
|
3403
3509
|
}) {
|
|
3404
|
-
const
|
|
3405
|
-
if (!
|
|
3510
|
+
const u = (e == null ? void 0 : e.rawPayload) || a;
|
|
3511
|
+
if (!u)
|
|
3406
3512
|
throw new Error(
|
|
3407
3513
|
"No 'rawPayload' or 'deposit' data provided. Please provide 'rawPayload' or 'deposit' parameter."
|
|
3408
3514
|
);
|
|
3409
|
-
const
|
|
3515
|
+
const s = A({ chainId: t, rpcUrl: r, env: o }), p = await R(
|
|
3410
3516
|
i,
|
|
3411
3517
|
t,
|
|
3412
|
-
|
|
3413
|
-
|
|
3518
|
+
o,
|
|
3519
|
+
S.Adapter
|
|
3414
3520
|
);
|
|
3415
3521
|
let y;
|
|
3416
|
-
if (i === d.BTCb && (t ===
|
|
3417
|
-
y = await
|
|
3418
|
-
abi:
|
|
3419
|
-
address:
|
|
3522
|
+
if (i === d.BTCb && (t === K.avalanche || t === K.avalancheFuji))
|
|
3523
|
+
y = await s.readContract({
|
|
3524
|
+
abi: p.abi,
|
|
3525
|
+
address: p.address,
|
|
3420
3526
|
functionName: "getBascule"
|
|
3421
3527
|
});
|
|
3422
|
-
else if (
|
|
3423
|
-
const l = await
|
|
3424
|
-
abi:
|
|
3425
|
-
address:
|
|
3528
|
+
else if (L(p.abi) && i === d.LBTC) {
|
|
3529
|
+
const l = await s.readContract({
|
|
3530
|
+
abi: p.abi,
|
|
3531
|
+
address: p.address,
|
|
3426
3532
|
functionName: "getAssetRouter"
|
|
3427
3533
|
});
|
|
3428
|
-
y = await
|
|
3429
|
-
abi:
|
|
3534
|
+
y = await s.readContract({
|
|
3535
|
+
abi: U,
|
|
3430
3536
|
address: l,
|
|
3431
3537
|
functionName: "bascule"
|
|
3432
3538
|
});
|
|
3433
3539
|
} else
|
|
3434
|
-
y = await
|
|
3435
|
-
abi:
|
|
3436
|
-
address:
|
|
3540
|
+
y = await s.readContract({
|
|
3541
|
+
abi: p.abi,
|
|
3542
|
+
address: p.address,
|
|
3437
3543
|
functionName: "Bascule"
|
|
3438
3544
|
});
|
|
3439
3545
|
if (y === Ie)
|
|
3440
3546
|
return 1;
|
|
3441
3547
|
let m;
|
|
3442
|
-
if (
|
|
3548
|
+
if (n ? m = x({ provider: n, chainId: t }) : m = A({ chainId: t, rpcUrl: r }), !m)
|
|
3443
3549
|
throw new Error(
|
|
3444
3550
|
"Could not determine the client for the contract interactions. Please provide the 'provider' and 'chainId' parameters or 'chainId' and optionally the 'rpcUrl' parameter."
|
|
3445
3551
|
);
|
|
3446
|
-
const
|
|
3552
|
+
const c = (G(t) || Re(t) || Me(t) || xe(t) || De(t)) && i === d.LBTC;
|
|
3447
3553
|
try {
|
|
3448
|
-
if (
|
|
3449
|
-
const h =
|
|
3450
|
-
abi:
|
|
3554
|
+
if (c) {
|
|
3555
|
+
const h = u.startsWith("0x") ? u : `0x${u}`, w = it(h), D = rt(w, t), [, B] = await s.readContract({
|
|
3556
|
+
abi: ot,
|
|
3451
3557
|
address: y,
|
|
3452
3558
|
functionName: "mintHistory",
|
|
3453
|
-
args: [
|
|
3559
|
+
args: [D]
|
|
3454
3560
|
});
|
|
3455
|
-
return
|
|
3561
|
+
return B;
|
|
3456
3562
|
}
|
|
3457
|
-
const l =
|
|
3458
|
-
Buffer.from(
|
|
3563
|
+
const l = Te(
|
|
3564
|
+
Buffer.from(u.slice(8), "hex")
|
|
3459
3565
|
);
|
|
3460
|
-
return await
|
|
3461
|
-
abi:
|
|
3566
|
+
return await be({
|
|
3567
|
+
abi: ut,
|
|
3462
3568
|
address: y,
|
|
3463
|
-
client:
|
|
3569
|
+
client: s
|
|
3464
3570
|
}).read.depositHistory([
|
|
3465
3571
|
l
|
|
3466
3572
|
]);
|
|
3467
3573
|
} catch (l) {
|
|
3468
|
-
throw new Error(
|
|
3574
|
+
throw new Error($(l));
|
|
3469
3575
|
}
|
|
3470
3576
|
}
|
|
3471
|
-
async function
|
|
3577
|
+
async function It({
|
|
3472
3578
|
account: e,
|
|
3473
|
-
token:
|
|
3474
|
-
spender:
|
|
3579
|
+
token: a,
|
|
3580
|
+
spender: n,
|
|
3475
3581
|
amount: t,
|
|
3476
|
-
chainId:
|
|
3477
|
-
provider:
|
|
3582
|
+
chainId: r,
|
|
3583
|
+
provider: o,
|
|
3478
3584
|
rpcUrl: i,
|
|
3479
|
-
env:
|
|
3585
|
+
env: u
|
|
3480
3586
|
}) {
|
|
3481
|
-
const
|
|
3587
|
+
const s = A({ chainId: r, rpcUrl: i, env: u }), p = x({ chainId: r, provider: o }), y = await O(a, r, u, i);
|
|
3482
3588
|
if (!y)
|
|
3483
|
-
throw new Error(`Token info not found for ${
|
|
3484
|
-
const m =
|
|
3485
|
-
|
|
3486
|
-
), { request:
|
|
3589
|
+
throw new Error(`Token info not found for ${a} on chain ${r}`);
|
|
3590
|
+
const m = _(
|
|
3591
|
+
F(f(t), y.decimals)
|
|
3592
|
+
), { request: c } = await s.simulateContract({
|
|
3487
3593
|
address: y.address,
|
|
3488
3594
|
account: e,
|
|
3489
|
-
chain:
|
|
3595
|
+
chain: C[r],
|
|
3490
3596
|
abi: y.abi,
|
|
3491
3597
|
functionName: "approve",
|
|
3492
|
-
args: [
|
|
3598
|
+
args: [n, m]
|
|
3493
3599
|
});
|
|
3494
|
-
return await
|
|
3600
|
+
return await p.writeContract(c);
|
|
3495
3601
|
}
|
|
3496
|
-
async function
|
|
3602
|
+
async function $t({
|
|
3497
3603
|
token: e,
|
|
3498
|
-
owner:
|
|
3499
|
-
spender:
|
|
3604
|
+
owner: a,
|
|
3605
|
+
spender: n,
|
|
3500
3606
|
chainId: t,
|
|
3501
|
-
rpcUrl:
|
|
3502
|
-
env:
|
|
3607
|
+
rpcUrl: r,
|
|
3608
|
+
env: o
|
|
3503
3609
|
}) {
|
|
3504
|
-
const i =
|
|
3505
|
-
if (!
|
|
3610
|
+
const i = A({ chainId: t, rpcUrl: r, env: o }), u = await O(e, t, o, r);
|
|
3611
|
+
if (!u)
|
|
3506
3612
|
throw new Error(`Token info not found for ${e} on chain ${t}`);
|
|
3507
|
-
const
|
|
3508
|
-
address:
|
|
3509
|
-
abi:
|
|
3613
|
+
const s = await i.readContract({
|
|
3614
|
+
address: u.address,
|
|
3615
|
+
abi: u.abi,
|
|
3510
3616
|
functionName: "allowance",
|
|
3511
|
-
args: [
|
|
3617
|
+
args: [a, n]
|
|
3512
3618
|
});
|
|
3513
|
-
return
|
|
3619
|
+
return W(s.toString(), u.decimals);
|
|
3514
3620
|
}
|
|
3515
|
-
const
|
|
3516
|
-
const t = await e.estimateFeesPerGas(),
|
|
3621
|
+
const ie = async (e, a, n) => {
|
|
3622
|
+
const t = await e.estimateFeesPerGas(), r = f(String(t.maxFeePerGas)).dividedBy(
|
|
3517
3623
|
String(t.maxPriorityFeePerGas)
|
|
3518
|
-
),
|
|
3519
|
-
|
|
3624
|
+
), o = n || t.maxPriorityFeePerGas, i = n ? BigInt(
|
|
3625
|
+
f(String(o)).multipliedBy(r).toFixed(0)
|
|
3520
3626
|
) : t.maxFeePerGas;
|
|
3521
3627
|
return {
|
|
3522
|
-
gas: await e.estimateContractGas(
|
|
3628
|
+
gas: await e.estimateContractGas(a),
|
|
3523
3629
|
maxFeePerGas: i,
|
|
3524
|
-
maxPriorityFeePerGas:
|
|
3630
|
+
maxPriorityFeePerGas: o
|
|
3525
3631
|
};
|
|
3526
3632
|
};
|
|
3527
|
-
async function
|
|
3633
|
+
async function yt({
|
|
3528
3634
|
data: e,
|
|
3529
|
-
proofSignature:
|
|
3530
|
-
account:
|
|
3635
|
+
proofSignature: a,
|
|
3636
|
+
account: n,
|
|
3531
3637
|
chainId: t,
|
|
3532
|
-
provider:
|
|
3533
|
-
rpcUrl:
|
|
3638
|
+
provider: r,
|
|
3639
|
+
rpcUrl: o,
|
|
3534
3640
|
env: i,
|
|
3535
|
-
token:
|
|
3641
|
+
token: u = d.LBTC
|
|
3536
3642
|
}) {
|
|
3537
|
-
if (![d.LBTC, d.BTCK, d.BTCb].includes(
|
|
3643
|
+
if (![d.LBTC, d.BTCK, d.BTCb].includes(u))
|
|
3538
3644
|
throw new Error("Unsupported token");
|
|
3539
|
-
if (
|
|
3645
|
+
if (u === d.BTCK && !G(t))
|
|
3540
3646
|
throw new Error("Operation not permitted");
|
|
3541
|
-
const
|
|
3542
|
-
|
|
3647
|
+
const s = await R(
|
|
3648
|
+
u,
|
|
3543
3649
|
t,
|
|
3544
3650
|
i,
|
|
3545
|
-
|
|
3546
|
-
),
|
|
3651
|
+
S.Adapter
|
|
3652
|
+
), p = await pt({
|
|
3547
3653
|
chainId: t,
|
|
3548
3654
|
rawPayload: e,
|
|
3549
3655
|
env: i,
|
|
3550
|
-
token:
|
|
3656
|
+
token: u
|
|
3551
3657
|
});
|
|
3552
|
-
if (
|
|
3553
|
-
switch (
|
|
3554
|
-
case
|
|
3658
|
+
if (p !== z.REPORTED)
|
|
3659
|
+
switch (p) {
|
|
3660
|
+
case z.UNREPORTED:
|
|
3555
3661
|
throw new Error(
|
|
3556
3662
|
"The deposit cannot be claimed because it is unreported or potentially still pending, please try again later."
|
|
3557
3663
|
);
|
|
3558
|
-
case
|
|
3664
|
+
case z.WITHDRAWN:
|
|
3559
3665
|
throw new Error(
|
|
3560
3666
|
"The deposit cannot be claimed because it is withdrawn already."
|
|
3561
3667
|
);
|
|
@@ -3564,121 +3670,121 @@ async function tt({
|
|
|
3564
3670
|
"The deposit cannot be claimed because it is blocked by bridge security."
|
|
3565
3671
|
);
|
|
3566
3672
|
}
|
|
3567
|
-
const y =
|
|
3568
|
-
address:
|
|
3569
|
-
account:
|
|
3570
|
-
chain:
|
|
3571
|
-
abi:
|
|
3572
|
-
functionName:
|
|
3573
|
-
args: [
|
|
3574
|
-
}, l =
|
|
3575
|
-
...
|
|
3673
|
+
const y = A({ chainId: t, rpcUrl: o, env: i }), m = x({ chainId: t, provider: r }), c = {
|
|
3674
|
+
address: s.address,
|
|
3675
|
+
account: n,
|
|
3676
|
+
chain: C[t],
|
|
3677
|
+
abi: s.abi,
|
|
3678
|
+
functionName: u === d.BTCK || u === d.BTCb ? "mintV1" : "mint",
|
|
3679
|
+
args: [ye(e), ye(a)]
|
|
3680
|
+
}, l = G(t) ? await ie(y, c, ae("1")) : {}, { request: b } = await y.simulateContract({
|
|
3681
|
+
...c,
|
|
3576
3682
|
...l
|
|
3577
3683
|
});
|
|
3578
|
-
return await m.writeContract(
|
|
3684
|
+
return await m.writeContract(b);
|
|
3579
3685
|
}
|
|
3580
|
-
async function
|
|
3686
|
+
async function Ft({
|
|
3581
3687
|
data: e,
|
|
3582
|
-
proofSignature:
|
|
3583
|
-
account:
|
|
3688
|
+
proofSignature: a,
|
|
3689
|
+
account: n,
|
|
3584
3690
|
chainId: t,
|
|
3585
|
-
provider:
|
|
3586
|
-
rpcUrl:
|
|
3691
|
+
provider: r,
|
|
3692
|
+
rpcUrl: o,
|
|
3587
3693
|
env: i
|
|
3588
3694
|
}) {
|
|
3589
|
-
return
|
|
3695
|
+
return yt({
|
|
3590
3696
|
data: e,
|
|
3591
|
-
proofSignature:
|
|
3592
|
-
account:
|
|
3697
|
+
proofSignature: a,
|
|
3698
|
+
account: n,
|
|
3593
3699
|
chainId: t,
|
|
3594
|
-
provider:
|
|
3595
|
-
rpcUrl:
|
|
3700
|
+
provider: r,
|
|
3701
|
+
rpcUrl: o,
|
|
3596
3702
|
env: i,
|
|
3597
3703
|
token: d.LBTC
|
|
3598
3704
|
});
|
|
3599
3705
|
}
|
|
3600
|
-
const
|
|
3706
|
+
const dt = [
|
|
3601
3707
|
{
|
|
3602
3708
|
tokenIn: d.BTCb,
|
|
3603
3709
|
tokenOut: d.LBTC
|
|
3604
3710
|
}
|
|
3605
3711
|
];
|
|
3606
|
-
async function
|
|
3712
|
+
async function Lt({
|
|
3607
3713
|
tokenIn: e,
|
|
3608
|
-
chainId:
|
|
3609
|
-
env:
|
|
3714
|
+
chainId: a,
|
|
3715
|
+
env: n,
|
|
3610
3716
|
rpcUrl: t
|
|
3611
3717
|
}) {
|
|
3612
|
-
const
|
|
3718
|
+
const r = A({ chainId: a, rpcUrl: t, env: n }), o = await R(
|
|
3613
3719
|
e,
|
|
3614
|
-
n,
|
|
3615
3720
|
a,
|
|
3616
|
-
|
|
3721
|
+
n,
|
|
3722
|
+
S.Adapter
|
|
3617
3723
|
);
|
|
3618
|
-
return await
|
|
3619
|
-
address:
|
|
3620
|
-
abi:
|
|
3724
|
+
return await r.readContract({
|
|
3725
|
+
address: o.address,
|
|
3726
|
+
abi: o.abi,
|
|
3621
3727
|
functionName: "getAssetRouter"
|
|
3622
3728
|
});
|
|
3623
3729
|
}
|
|
3624
|
-
async function
|
|
3730
|
+
async function Ot({
|
|
3625
3731
|
account: e,
|
|
3626
|
-
amount:
|
|
3627
|
-
chainId:
|
|
3732
|
+
amount: a,
|
|
3733
|
+
chainId: n,
|
|
3628
3734
|
env: t,
|
|
3629
|
-
provider:
|
|
3630
|
-
rpcUrl:
|
|
3735
|
+
provider: r,
|
|
3736
|
+
rpcUrl: o,
|
|
3631
3737
|
tokenIn: i = d.BTCb,
|
|
3632
|
-
tokenOut:
|
|
3738
|
+
tokenOut: u = d.LBTC
|
|
3633
3739
|
}) {
|
|
3634
|
-
if (!
|
|
3635
|
-
(
|
|
3740
|
+
if (!dt.find(
|
|
3741
|
+
(I) => I.tokenIn === i && I.tokenOut === u
|
|
3636
3742
|
))
|
|
3637
|
-
throw new
|
|
3638
|
-
const
|
|
3743
|
+
throw new me(i, u, n, t);
|
|
3744
|
+
const p = A({ chainId: n, rpcUrl: o, env: t }), y = x({ provider: r, chainId: n }), m = await R(
|
|
3639
3745
|
i,
|
|
3640
|
-
|
|
3746
|
+
n,
|
|
3641
3747
|
t,
|
|
3642
|
-
|
|
3643
|
-
),
|
|
3748
|
+
S.Adapter
|
|
3749
|
+
), c = await R(
|
|
3644
3750
|
i,
|
|
3645
|
-
|
|
3751
|
+
n,
|
|
3646
3752
|
t,
|
|
3647
|
-
|
|
3648
|
-
), l = await
|
|
3649
|
-
|
|
3650
|
-
|
|
3753
|
+
S.Token
|
|
3754
|
+
), l = await R(
|
|
3755
|
+
u,
|
|
3756
|
+
n,
|
|
3651
3757
|
t,
|
|
3652
|
-
|
|
3653
|
-
),
|
|
3654
|
-
if (!
|
|
3758
|
+
S.Token
|
|
3759
|
+
), b = await ce(p, c);
|
|
3760
|
+
if (!b)
|
|
3655
3761
|
throw new Error(
|
|
3656
|
-
`Could not retrieve the properties of ${i} on ${
|
|
3762
|
+
`Could not retrieve the properties of ${i} on ${n}`
|
|
3657
3763
|
);
|
|
3658
|
-
const
|
|
3764
|
+
const T = await p.readContract({
|
|
3659
3765
|
address: m.address,
|
|
3660
3766
|
abi: m.abi,
|
|
3661
3767
|
functionName: "getAssetRouter"
|
|
3662
|
-
}), h =
|
|
3663
|
-
address:
|
|
3664
|
-
abi:
|
|
3768
|
+
}), h = f(a), w = _(F(h, b.decimals)), D = await p.readContract({
|
|
3769
|
+
address: b.address,
|
|
3770
|
+
abi: b.abi,
|
|
3665
3771
|
functionName: "balanceOf",
|
|
3666
3772
|
args: [e]
|
|
3667
|
-
}),
|
|
3668
|
-
if (h.isGreaterThan(
|
|
3773
|
+
}), B = W(D, b.decimals);
|
|
3774
|
+
if (h.isGreaterThan(B))
|
|
3669
3775
|
throw new Error(
|
|
3670
|
-
`Unable to deposit ${h.toString()} ${
|
|
3776
|
+
`Unable to deposit ${h.toString()} ${b.symbol} because the amount exceeds the account's balance of ${B.toString()} ${b.symbol}`
|
|
3671
3777
|
);
|
|
3672
3778
|
return await y.writeContract({
|
|
3673
|
-
address:
|
|
3674
|
-
abi:
|
|
3675
|
-
chain:
|
|
3779
|
+
address: T,
|
|
3780
|
+
abi: U,
|
|
3781
|
+
chain: C[n],
|
|
3676
3782
|
functionName: "deposit",
|
|
3677
|
-
args: [e, l.address,
|
|
3783
|
+
args: [e, l.address, w],
|
|
3678
3784
|
account: e
|
|
3679
3785
|
});
|
|
3680
3786
|
}
|
|
3681
|
-
const
|
|
3787
|
+
const lt = [
|
|
3682
3788
|
// Redeem to BTC
|
|
3683
3789
|
{ tokenIn: d.LBTC },
|
|
3684
3790
|
// -> BTC
|
|
@@ -3692,188 +3798,435 @@ const at = [
|
|
|
3692
3798
|
{ tokenIn: d.LBTC, tokenOut: d.BTCK }
|
|
3693
3799
|
// -> Native LBTC
|
|
3694
3800
|
];
|
|
3695
|
-
async function
|
|
3801
|
+
async function mt(e) {
|
|
3696
3802
|
const {
|
|
3697
|
-
account:
|
|
3698
|
-
amount:
|
|
3803
|
+
account: a,
|
|
3804
|
+
amount: n,
|
|
3699
3805
|
btcAddress: t,
|
|
3700
|
-
chainId:
|
|
3701
|
-
env:
|
|
3806
|
+
chainId: r,
|
|
3807
|
+
env: o,
|
|
3702
3808
|
rpcUrl: i,
|
|
3703
|
-
tokenIn:
|
|
3704
|
-
tokenOut:
|
|
3809
|
+
tokenIn: u = d.LBTC,
|
|
3810
|
+
tokenOut: s
|
|
3705
3811
|
} = e;
|
|
3706
|
-
if (!
|
|
3707
|
-
(
|
|
3812
|
+
if (!lt.find(
|
|
3813
|
+
(E) => E.tokenIn === u && E.tokenOut === s
|
|
3708
3814
|
))
|
|
3709
|
-
throw new
|
|
3710
|
-
const y =
|
|
3711
|
-
|
|
3712
|
-
s,
|
|
3815
|
+
throw new me(u, s || "BTC", r, o);
|
|
3816
|
+
const y = A({ chainId: r, rpcUrl: i, env: o }), m = se(e) ? x({ provider: e.provider, chainId: r }) : void 0, c = await R(
|
|
3817
|
+
u,
|
|
3713
3818
|
r,
|
|
3714
|
-
|
|
3819
|
+
o,
|
|
3820
|
+
S.Token
|
|
3715
3821
|
// get the token contract, not adapter
|
|
3716
|
-
), l = await
|
|
3822
|
+
), l = await ce(y, c);
|
|
3717
3823
|
if (!l)
|
|
3718
3824
|
throw new Error(
|
|
3719
|
-
`Could not retrieve the properties of ${
|
|
3825
|
+
`Could not retrieve the properties of ${u} on ${r}`
|
|
3720
3826
|
);
|
|
3721
|
-
const
|
|
3827
|
+
const b = F(n, l.decimals), T = await y.readContract({
|
|
3722
3828
|
address: l.address,
|
|
3723
3829
|
abi: l.abi,
|
|
3724
3830
|
functionName: "balanceOf",
|
|
3725
|
-
args: [
|
|
3726
|
-
}), h =
|
|
3727
|
-
if (
|
|
3831
|
+
args: [a]
|
|
3832
|
+
}), h = W(T, l.decimals);
|
|
3833
|
+
if (b.isGreaterThan(T))
|
|
3728
3834
|
throw new Error(
|
|
3729
|
-
`Unable to redeem ${String(
|
|
3835
|
+
`Unable to redeem ${String(n)} ${l.symbol} because the amount exceeds the account's balance of ${h.toString()} ${l.symbol}`
|
|
3730
3836
|
);
|
|
3731
|
-
if (!
|
|
3837
|
+
if (!s) {
|
|
3732
3838
|
if (!t)
|
|
3733
3839
|
throw new Error("Missing parameter: `btcAddress`.");
|
|
3734
|
-
const
|
|
3735
|
-
if (
|
|
3736
|
-
const
|
|
3737
|
-
|
|
3738
|
-
s,
|
|
3840
|
+
const E = await Ee(t, o);
|
|
3841
|
+
if (u === d.BTCb && (r === K.avalanche || r === K.avalancheFuji)) {
|
|
3842
|
+
const M = await R(
|
|
3843
|
+
u,
|
|
3739
3844
|
r,
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3845
|
+
o,
|
|
3846
|
+
S.Adapter
|
|
3847
|
+
), N = await y.readContract({
|
|
3848
|
+
address: M.address,
|
|
3849
|
+
abi: M.abi,
|
|
3744
3850
|
functionName: "getAssetRouter"
|
|
3745
|
-
}),
|
|
3851
|
+
}), te = await y.readContract({
|
|
3746
3852
|
address: l.address,
|
|
3747
3853
|
abi: l.abi,
|
|
3748
3854
|
functionName: "allowance",
|
|
3749
|
-
args: [
|
|
3855
|
+
args: [a, M.address]
|
|
3750
3856
|
});
|
|
3751
|
-
if (
|
|
3752
|
-
const { txHash:
|
|
3857
|
+
if (b.isGreaterThan(te)) {
|
|
3858
|
+
const { txHash: v } = await q({
|
|
3753
3859
|
params: e,
|
|
3754
3860
|
publicClient: y,
|
|
3755
3861
|
walletClient: m,
|
|
3756
3862
|
simulateArgs: {
|
|
3757
3863
|
address: l.address,
|
|
3758
3864
|
abi: l.abi,
|
|
3759
|
-
account:
|
|
3865
|
+
account: a,
|
|
3760
3866
|
functionName: "approve",
|
|
3761
|
-
args: [
|
|
3867
|
+
args: [M.address, _(b)]
|
|
3762
3868
|
},
|
|
3763
3869
|
operation: "BTC.b approval"
|
|
3764
|
-
}),
|
|
3870
|
+
}), ue = await nt(
|
|
3765
3871
|
y,
|
|
3766
|
-
|
|
3872
|
+
v,
|
|
3767
3873
|
"BTC.b approval"
|
|
3768
3874
|
);
|
|
3769
3875
|
console.info(
|
|
3770
|
-
`Approved adapter (${
|
|
3771
|
-
|
|
3772
|
-
|
|
3876
|
+
`Approved adapter (${M.address}) for ${new f(n).toString()} ${l.symbol}`,
|
|
3877
|
+
ue.transactionHash,
|
|
3878
|
+
ue.status
|
|
3773
3879
|
);
|
|
3774
3880
|
}
|
|
3775
|
-
const { txHash:
|
|
3881
|
+
const { txHash: ne } = await q({
|
|
3776
3882
|
params: e,
|
|
3777
3883
|
publicClient: y,
|
|
3778
3884
|
walletClient: m,
|
|
3779
3885
|
simulateArgs: {
|
|
3780
|
-
address:
|
|
3781
|
-
abi:
|
|
3782
|
-
account:
|
|
3886
|
+
address: N,
|
|
3887
|
+
abi: U,
|
|
3888
|
+
account: a,
|
|
3783
3889
|
functionName: "redeemForBtc",
|
|
3784
3890
|
args: [
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3891
|
+
a,
|
|
3892
|
+
M.address,
|
|
3893
|
+
E,
|
|
3894
|
+
_(b)
|
|
3789
3895
|
]
|
|
3790
3896
|
},
|
|
3791
3897
|
operation: "BTC.b redeemForBtc"
|
|
3792
3898
|
});
|
|
3793
|
-
return
|
|
3899
|
+
return ne;
|
|
3794
3900
|
}
|
|
3795
|
-
const
|
|
3901
|
+
const I = {
|
|
3796
3902
|
abi: l.abi,
|
|
3797
3903
|
address: l.address,
|
|
3798
|
-
account:
|
|
3799
|
-
chain:
|
|
3800
|
-
functionName:
|
|
3904
|
+
account: a,
|
|
3905
|
+
chain: C[r],
|
|
3906
|
+
functionName: L(l.abi) || u === d.BTCb ? "redeemForBtc" : "redeem",
|
|
3801
3907
|
// legacy
|
|
3802
|
-
args: [
|
|
3803
|
-
},
|
|
3908
|
+
args: [E, _(b)]
|
|
3909
|
+
}, V = G(r) ? await ie(y, I, ae("1")) : {}, { txHash: P } = await q({
|
|
3804
3910
|
params: e,
|
|
3805
3911
|
publicClient: y,
|
|
3806
3912
|
walletClient: m,
|
|
3807
3913
|
simulateArgs: {
|
|
3808
|
-
...
|
|
3809
|
-
account:
|
|
3810
|
-
...
|
|
3914
|
+
...I,
|
|
3915
|
+
account: a,
|
|
3916
|
+
...V
|
|
3811
3917
|
},
|
|
3812
|
-
operation: `${
|
|
3918
|
+
operation: `${u} redeem to BTC`
|
|
3813
3919
|
});
|
|
3814
|
-
return
|
|
3920
|
+
return P;
|
|
3815
3921
|
}
|
|
3816
|
-
if (!
|
|
3922
|
+
if (!L(l.abi))
|
|
3817
3923
|
throw new Error(
|
|
3818
|
-
`The ${
|
|
3924
|
+
`The ${u} contract (${l.address}) doesn't support redemptions to ${s}.`
|
|
3819
3925
|
);
|
|
3820
|
-
const
|
|
3926
|
+
const w = {
|
|
3821
3927
|
abi: l.abi,
|
|
3822
3928
|
address: l.address,
|
|
3823
|
-
account:
|
|
3824
|
-
chain:
|
|
3929
|
+
account: a,
|
|
3930
|
+
chain: C[r],
|
|
3825
3931
|
functionName: "redeem",
|
|
3826
|
-
args: [
|
|
3827
|
-
},
|
|
3932
|
+
args: [_(b)]
|
|
3933
|
+
}, D = G(r) ? await ie(y, w, ae("1")) : {}, { txHash: B } = await q({
|
|
3828
3934
|
params: e,
|
|
3829
3935
|
publicClient: y,
|
|
3830
3936
|
walletClient: m,
|
|
3831
3937
|
simulateArgs: {
|
|
3832
|
-
...
|
|
3833
|
-
account:
|
|
3834
|
-
...
|
|
3938
|
+
...w,
|
|
3939
|
+
account: a,
|
|
3940
|
+
...D
|
|
3835
3941
|
},
|
|
3836
|
-
operation: `${
|
|
3942
|
+
operation: `${u} redeem to ${s}`
|
|
3837
3943
|
});
|
|
3838
|
-
return
|
|
3944
|
+
return B;
|
|
3839
3945
|
}
|
|
3840
|
-
async function
|
|
3841
|
-
return
|
|
3946
|
+
async function Ut(e) {
|
|
3947
|
+
return mt({
|
|
3842
3948
|
...e,
|
|
3843
3949
|
tokenIn: d.LBTC,
|
|
3844
3950
|
tokenOut: void 0
|
|
3845
3951
|
});
|
|
3846
3952
|
}
|
|
3953
|
+
async function Vt({
|
|
3954
|
+
amount: e,
|
|
3955
|
+
approve: a = !0,
|
|
3956
|
+
token: n = d.LBTC,
|
|
3957
|
+
account: t,
|
|
3958
|
+
chainId: r,
|
|
3959
|
+
provider: o,
|
|
3960
|
+
rpcUrl: i,
|
|
3961
|
+
env: u
|
|
3962
|
+
}) {
|
|
3963
|
+
const s = Z;
|
|
3964
|
+
if (!oe(r))
|
|
3965
|
+
throw new Error(
|
|
3966
|
+
`Unsupported chain id: ${r}. Please switch to one of the supported chains: ${s.chains.join(", ")}`
|
|
3967
|
+
);
|
|
3968
|
+
const p = A({ chainId: r, rpcUrl: i }), y = x({ provider: o, chainId: r }), m = await O(n, r, u, i);
|
|
3969
|
+
if (!m)
|
|
3970
|
+
throw new Error(`Unknown withdraw token: ${n}`);
|
|
3971
|
+
const c = f(e), l = _(F(c, s.decimals)), b = await p.readContract({
|
|
3972
|
+
address: s.lensContract.address,
|
|
3973
|
+
abi: s.lensContract.abi,
|
|
3974
|
+
functionName: "balanceOf",
|
|
3975
|
+
args: [t, s.vaultContract.address]
|
|
3976
|
+
}), T = W(String(b), s.decimals), h = await p.readContract({
|
|
3977
|
+
address: s.vaultContract.address,
|
|
3978
|
+
abi: s.vaultContract.abi,
|
|
3979
|
+
functionName: "allowance",
|
|
3980
|
+
args: [t, s.withdrawQueueContracts[r].address]
|
|
3981
|
+
}), w = W(String(h), s.decimals);
|
|
3982
|
+
if (c.isGreaterThan(T))
|
|
3983
|
+
throw new Error(
|
|
3984
|
+
`The withdraw amount exceeds the account's balance.
|
|
3985
|
+
Withdraw amount: ${c.toFixed()}
|
|
3986
|
+
Balance: ${T.toFixed()}`
|
|
3987
|
+
);
|
|
3988
|
+
if (c.isGreaterThan(w)) {
|
|
3989
|
+
const V = `The withdraw amount exceeds allowance.
|
|
3990
|
+
Withdraw amount: ${c.toFixed()}
|
|
3991
|
+
Allowance: ${w.toFixed()}`;
|
|
3992
|
+
if (!a)
|
|
3993
|
+
throw new Error(V);
|
|
3994
|
+
try {
|
|
3995
|
+
console.info(`Trying to approve ${l}`);
|
|
3996
|
+
const { request: P } = await p.simulateContract({
|
|
3997
|
+
account: t,
|
|
3998
|
+
chain: C[r],
|
|
3999
|
+
address: s.vaultContract.address,
|
|
4000
|
+
abi: s.vaultContract.abi,
|
|
4001
|
+
functionName: "approve",
|
|
4002
|
+
args: [s.withdrawQueueContracts[r].address, l]
|
|
4003
|
+
}), M = await y.writeContract(P);
|
|
4004
|
+
console.info(`Approve tx hash: ${M}`), console.info(`Approved ${l} for ${s.vaultContract.address}`);
|
|
4005
|
+
} catch (P) {
|
|
4006
|
+
const M = $(P);
|
|
4007
|
+
throw new Error(
|
|
4008
|
+
`Could not approve ${l} for ${s.vaultContract.address}.
|
|
4009
|
+
Reason: ${M}`
|
|
4010
|
+
);
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
const D = f(Date.now()).dividedBy(1e3).plus(f(s.queueWithdrawDaysValid).multipliedBy(ee / 1e3)).decimalPlaces(0, f.ROUND_DOWN), B = f(s.queueWithdrawDiscountPercent).multipliedBy(
|
|
4014
|
+
1e4
|
|
4015
|
+
// 1% = 10000
|
|
4016
|
+
), { request: E } = await p.simulateContract({
|
|
4017
|
+
account: t,
|
|
4018
|
+
chain: C[r],
|
|
4019
|
+
address: s.withdrawQueueContracts[r].address,
|
|
4020
|
+
abi: s.withdrawQueueContracts[r].abi,
|
|
4021
|
+
functionName: "safeUpdateAtomicRequest",
|
|
4022
|
+
args: [
|
|
4023
|
+
s.vaultContract.address,
|
|
4024
|
+
m.address,
|
|
4025
|
+
[D.toFixed(0), 0n, l, !1],
|
|
4026
|
+
s.accountantContract.address,
|
|
4027
|
+
B.toFixed(0)
|
|
4028
|
+
]
|
|
4029
|
+
});
|
|
4030
|
+
return await y.writeContract(E);
|
|
4031
|
+
}
|
|
4032
|
+
async function Wt({
|
|
4033
|
+
token: e = d.LBTC,
|
|
4034
|
+
account: a,
|
|
4035
|
+
chainId: n,
|
|
4036
|
+
provider: t,
|
|
4037
|
+
rpcUrl: r,
|
|
4038
|
+
env: o
|
|
4039
|
+
}) {
|
|
4040
|
+
const i = Z;
|
|
4041
|
+
if (!oe(n))
|
|
4042
|
+
throw new Error(
|
|
4043
|
+
`Unsupported chain id: ${n}. Please switch to one of the supported chains: ${i.chains.join(", ")}`
|
|
4044
|
+
);
|
|
4045
|
+
const u = A({ chainId: n, rpcUrl: r }), s = x({ provider: t, chainId: n }), p = await O(e, n, o, r);
|
|
4046
|
+
if (!p)
|
|
4047
|
+
throw new Error(`Unknown withdraw token: ${e}`);
|
|
4048
|
+
const { request: y } = await u.simulateContract({
|
|
4049
|
+
account: a,
|
|
4050
|
+
chain: C[n],
|
|
4051
|
+
address: i.withdrawQueueContracts[n].address,
|
|
4052
|
+
abi: i.withdrawQueueContracts[n].abi,
|
|
4053
|
+
functionName: "updateAtomicRequest",
|
|
4054
|
+
args: [
|
|
4055
|
+
i.vaultContract.address,
|
|
4056
|
+
p.address,
|
|
4057
|
+
[0, 0, 0, !1]
|
|
4058
|
+
]
|
|
4059
|
+
});
|
|
4060
|
+
return await s.writeContract(y);
|
|
4061
|
+
}
|
|
4062
|
+
async function Gt({
|
|
4063
|
+
amount: e,
|
|
4064
|
+
withdrawalAsset: a = d.LBTC,
|
|
4065
|
+
account: n,
|
|
4066
|
+
chainId: t,
|
|
4067
|
+
provider: r,
|
|
4068
|
+
rpcUrl: o,
|
|
4069
|
+
env: i
|
|
4070
|
+
}) {
|
|
4071
|
+
if (!oe(t))
|
|
4072
|
+
throw new Error(
|
|
4073
|
+
`Unsupported chain ${t}. Earn withdrawals are supported on: ${Z.chains.join(", ")}.`
|
|
4074
|
+
);
|
|
4075
|
+
const u = f(e);
|
|
4076
|
+
if (!u.isGreaterThan(0))
|
|
4077
|
+
throw new Error(
|
|
4078
|
+
`Withdraw amount must be greater than zero. Received: ${u.toFixed()}.`
|
|
4079
|
+
);
|
|
4080
|
+
const s = Z, p = s.vaultContract.address, y = s.accountantContract.address, m = s.lensContract.address, c = s.withdrawQueueContracts[t].address, l = s.withdrawQueueContracts[t].abi, b = await O(
|
|
4081
|
+
a,
|
|
4082
|
+
t,
|
|
4083
|
+
i,
|
|
4084
|
+
o
|
|
4085
|
+
);
|
|
4086
|
+
if (!b)
|
|
4087
|
+
throw new Error(
|
|
4088
|
+
`Could not resolve withdrawal asset ${a} on chain ${t}.`
|
|
4089
|
+
);
|
|
4090
|
+
const T = A({ chainId: t, rpcUrl: o }), h = x({ provider: r, chainId: t }), w = _(F(u, s.decimals)), D = re(t), B = await Promise.all([
|
|
4091
|
+
T.readContract({
|
|
4092
|
+
address: m,
|
|
4093
|
+
abi: s.lensContract.abi,
|
|
4094
|
+
functionName: "balanceOf",
|
|
4095
|
+
args: [n, p]
|
|
4096
|
+
}),
|
|
4097
|
+
D ? T.readContract({
|
|
4098
|
+
address: k.contracts[t],
|
|
4099
|
+
abi: k.abi,
|
|
4100
|
+
functionName: "balanceOf",
|
|
4101
|
+
args: [n]
|
|
4102
|
+
}) : Promise.resolve(0n),
|
|
4103
|
+
T.readContract({
|
|
4104
|
+
address: p,
|
|
4105
|
+
abi: j,
|
|
4106
|
+
functionName: "allowance",
|
|
4107
|
+
args: [n, c]
|
|
4108
|
+
})
|
|
4109
|
+
]), E = B[0], I = B[1], V = B[2];
|
|
4110
|
+
if (w > E + I)
|
|
4111
|
+
throw new Error(
|
|
4112
|
+
`InsufficientPositionError: requested ${u.toFixed()} exceeds total position. underlyingBalance=${E.toString()}, btceBalance=${I.toString()}, amount=${w.toString()}.`
|
|
4113
|
+
);
|
|
4114
|
+
const P = w > E ? w - E : 0n;
|
|
4115
|
+
let M = 0n;
|
|
4116
|
+
if (D && P > 0n) {
|
|
4117
|
+
const v = await T.readContract({
|
|
4118
|
+
address: k.contracts[t],
|
|
4119
|
+
abi: k.abi,
|
|
4120
|
+
functionName: "maxWithdraw",
|
|
4121
|
+
args: [n]
|
|
4122
|
+
});
|
|
4123
|
+
if (v < P)
|
|
4124
|
+
throw new Error(
|
|
4125
|
+
`InsufficientUnwrappableError: needed ${P.toString()} but BTCe.maxWithdraw(${n}) returned ${v.toString()}. The wrapper position may have shrunk between balance read and unwrap. No transactions sent.`
|
|
4126
|
+
);
|
|
4127
|
+
M = P;
|
|
4128
|
+
}
|
|
4129
|
+
const N = {
|
|
4130
|
+
queueTxHash: "0x"
|
|
4131
|
+
// overwritten below
|
|
4132
|
+
};
|
|
4133
|
+
if (V < w)
|
|
4134
|
+
try {
|
|
4135
|
+
const { request: v } = await T.simulateContract({
|
|
4136
|
+
account: n,
|
|
4137
|
+
chain: C[t],
|
|
4138
|
+
address: p,
|
|
4139
|
+
abi: j,
|
|
4140
|
+
functionName: "approve",
|
|
4141
|
+
args: [c, $e]
|
|
4142
|
+
});
|
|
4143
|
+
N.approveTxHash = await h.writeContract(v), await T.waitForTransactionReceipt({
|
|
4144
|
+
hash: N.approveTxHash
|
|
4145
|
+
});
|
|
4146
|
+
} catch (v) {
|
|
4147
|
+
throw new Error(
|
|
4148
|
+
`Approval of underlying share for withdraw queue failed: ${$(v)}`
|
|
4149
|
+
);
|
|
4150
|
+
}
|
|
4151
|
+
if (M > 0n && D)
|
|
4152
|
+
try {
|
|
4153
|
+
const { request: v } = await T.simulateContract({
|
|
4154
|
+
account: n,
|
|
4155
|
+
chain: C[t],
|
|
4156
|
+
address: k.contracts[t],
|
|
4157
|
+
abi: k.abi,
|
|
4158
|
+
functionName: "withdraw",
|
|
4159
|
+
args: [M, n, n]
|
|
4160
|
+
});
|
|
4161
|
+
N.unwrapTxHash = await h.writeContract(v), await T.waitForTransactionReceipt({
|
|
4162
|
+
hash: N.unwrapTxHash
|
|
4163
|
+
});
|
|
4164
|
+
} catch (v) {
|
|
4165
|
+
throw new Error(
|
|
4166
|
+
`Unwrap from BTCe to underlying share failed: ${$(v)}. Approval${N.approveTxHash ? ` (${N.approveTxHash})` : ""} may already be in place.`
|
|
4167
|
+
);
|
|
4168
|
+
}
|
|
4169
|
+
const te = f(Date.now()).dividedBy(1e3).plus(f(s.queueWithdrawDaysValid).multipliedBy(ee / 1e3)).decimalPlaces(0, f.ROUND_DOWN), ne = f(s.queueWithdrawDiscountPercent).multipliedBy(
|
|
4170
|
+
1e4
|
|
4171
|
+
);
|
|
4172
|
+
try {
|
|
4173
|
+
const { request: v } = await T.simulateContract({
|
|
4174
|
+
account: n,
|
|
4175
|
+
chain: C[t],
|
|
4176
|
+
address: c,
|
|
4177
|
+
abi: l,
|
|
4178
|
+
functionName: "safeUpdateAtomicRequest",
|
|
4179
|
+
args: [
|
|
4180
|
+
p,
|
|
4181
|
+
b.address,
|
|
4182
|
+
[BigInt(te.toFixed(0)), 0n, w, !1],
|
|
4183
|
+
y,
|
|
4184
|
+
BigInt(ne.toFixed(0))
|
|
4185
|
+
]
|
|
4186
|
+
});
|
|
4187
|
+
N.queueTxHash = await h.writeContract(v);
|
|
4188
|
+
} catch (v) {
|
|
4189
|
+
throw new Error(
|
|
4190
|
+
`Queue withdrawal failed: ${$(v)}. Prior steps may have completed: approve=${N.approveTxHash ?? "n/a"}, unwrap=${N.unwrapTxHash ?? "n/a"}.`
|
|
4191
|
+
);
|
|
4192
|
+
}
|
|
4193
|
+
return N;
|
|
4194
|
+
}
|
|
3847
4195
|
export {
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
4196
|
+
U as ASSET_ROUTER_ABI,
|
|
4197
|
+
z as BasculeDepositStatus,
|
|
4198
|
+
g as SignerError,
|
|
4199
|
+
It as approveToken,
|
|
4200
|
+
Wt as cancelWithdrawInternal,
|
|
4201
|
+
Ft as claimLBTC,
|
|
4202
|
+
tt as createAccountFromSigner,
|
|
4203
|
+
Pt as createWalletClientFromSigner,
|
|
4204
|
+
_t as depositEarn,
|
|
4205
|
+
Ot as depositToken,
|
|
4206
|
+
ie as estimateGasFees,
|
|
4207
|
+
qe as getAddressConfirmationMessage,
|
|
4208
|
+
Lt as getAssetRouterAddress,
|
|
4209
|
+
pt as getBasculeDepositStatus,
|
|
4210
|
+
Dt as getLBTCBurningFee,
|
|
4211
|
+
xt as getLBTCMintingFee,
|
|
4212
|
+
Ge as getMinRedeemAmount,
|
|
4213
|
+
Et as getMinRedeemAmountWithFee,
|
|
4214
|
+
We as getMintingFee,
|
|
4215
|
+
ze as getPermitNonce,
|
|
4216
|
+
ge as getRedeemFee,
|
|
4217
|
+
Ae as getStakeAndBakeConfig,
|
|
4218
|
+
Bt as getStakeAndBakeFee,
|
|
4219
|
+
$t as getTokenAllowance,
|
|
4220
|
+
yt as mintToken,
|
|
4221
|
+
Vt as queueWithdrawInternal,
|
|
4222
|
+
mt as redeemToken,
|
|
4223
|
+
Nt as signLbtcDestinationAddr,
|
|
4224
|
+
St as signNetworkFee,
|
|
4225
|
+
kt as signStakeAndBake,
|
|
4226
|
+
Ut as unstakeLBTC,
|
|
4227
|
+
ve as validateTransactionRequest,
|
|
4228
|
+
nt as waitForTransactionReceipt,
|
|
4229
|
+
Gt as withdrawEarn,
|
|
4230
|
+
et as wrapToBtce
|
|
3878
4231
|
};
|
|
3879
|
-
//# sourceMappingURL=
|
|
4232
|
+
//# sourceMappingURL=withdrawEarn-QFaMhs0t.js.map
|