@lombard.finance/sdk 4.0.0 → 4.1.2
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 +12 -0
- package/dist/bridge/lib/ccip-config.d.ts.map +1 -1
- package/dist/bridge/lib/config.d.ts +3 -3
- package/dist/bridge/lib/config.d.ts.map +1 -1
- package/dist/common/chains.d.ts +2 -2
- package/dist/common/chains.d.ts.map +1 -1
- package/dist/common/feature-config.d.ts.map +1 -1
- package/dist/contract-functions/getBasculeDepositStatus/getBasculeDepositStatus.d.ts.map +1 -1
- package/dist/index2.cjs +6 -6
- package/dist/index2.js +792 -759
- package/dist/vaults/lib/config.d.ts +1 -1
- package/package.json +7 -8
- package/src/__tests__/AssetNamespace.spec.ts +0 -234
- package/src/__tests__/helpers/createTestConfig.ts +0 -90
- package/src/__tests__/integration/automint-fee.integration.test.ts +0 -74
- package/src/__tests__/integration/btc-deposit.integration.test.ts +0 -109
- package/src/__tests__/integration/btc-stake-and-deploy.integration.test.ts +0 -96
- package/src/__tests__/integration/btc-stake.integration.test.ts +0 -466
- package/src/__tests__/integration/evm-actions.integration.test.ts +0 -932
- package/src/__tests__/integration/evm-deploy.integration.test.ts +0 -122
- package/src/__tests__/integration/evm-redeem.integration.test.ts +0 -157
- package/src/__tests__/integration/faq-patterns.integration.test.ts +0 -465
- package/src/__tests__/integration/getLBTCMintingFee.integration.test.ts +0 -195
- package/src/__tests__/real-wallet/btc/btc-stake.real.test.ts +0 -70
- package/src/__tests__/real-wallet/evm/evm-stake.real.test.ts +0 -47
- package/src/__tests__/real-wallet/evm/evm-unstake.real.test.ts +0 -49
- package/src/__tests__/real-wallet/non-evm/solana-unstake.real.test.ts +0 -19
- package/src/__tests__/real-wallet/non-evm/starknet-unstake.real.test.ts +0 -19
- package/src/__tests__/real-wallet/non-evm/sui-unstake.real.test.ts +0 -19
- package/src/__tests__/services/ApiService.test.ts +0 -62
- package/src/__tests__/services/BtcService.test.ts +0 -30
- package/src/__tests__/services/EvmService.test.ts +0 -39
- package/src/__tests__/setup.ts +0 -16
- package/src/__tests__/test-utils/eip1193-adapter.ts +0 -48
- package/src/__tests__/test-utils/evm-wallet.ts +0 -38
- package/src/__tests__/test-utils/solana-wallet.ts +0 -22
- package/src/__tests__/test-utils/starknet-wallet.ts +0 -9
- package/src/__tests__/test-utils/sui-wallet.ts +0 -14
- package/src/__tests__/test-utils/test-constraints.ts +0 -110
- package/src/__tests__/unit/btc/BtcDeposit.test.ts +0 -253
- package/src/__tests__/unit/btc/BtcDepositAndDeploy.test.ts +0 -174
- package/src/__tests__/unit/btc/BtcDepositConfig.test.ts +0 -143
- package/src/__tests__/unit/btc/BtcDepositStatusTransition.test.ts +0 -221
- package/src/__tests__/unit/btc/BtcStakeAndDeploy.test.ts +0 -194
- package/src/__tests__/unit/btc/ExistingSignatureHandling.test.ts +0 -301
- package/src/__tests__/unit/btc/StakeAndBakeRatioConversion.test.ts +0 -200
- package/src/__tests__/unit/btc/StakeAndBakeSignatureRestore.test.ts +0 -216
- package/src/__tests__/unit/btc/TokenParameterConsistency.test.ts +0 -184
- package/src/__tests__/unit/btc/btc-deposit-token.test.ts +0 -191
- package/src/__tests__/unit/catalog/AssetCatalog.test.ts +0 -293
- package/src/__tests__/unit/config/ChainConfig.test.ts +0 -47
- package/src/__tests__/unit/config/FeeAuthConfig.test.ts +0 -76
- package/src/__tests__/unit/contract-functions/getLBTCMintingFee.test.ts +0 -128
- package/src/__tests__/unit/core/chain-parsing.test.ts +0 -257
- package/src/__tests__/unit/defi/AvailableProtocols.test.ts +0 -100
- package/src/__tests__/unit/defi/DefiRegistry.test.ts +0 -25
- package/src/__tests__/unit/evm/EvmDeploy.test.ts +0 -224
- package/src/__tests__/unit/evm/EvmRedeem.test.ts +0 -207
- package/src/__tests__/unit/evm/EvmRedeemFeeAuth.test.ts +0 -93
- package/src/__tests__/unit/evm/EvmStake.test.ts +0 -207
- package/src/__tests__/unit/evm/EvmStakeFeeAuth.test.ts +0 -193
- package/src/__tests__/unit/evm/EvmUnstakeAllowance.test.ts +0 -69
- package/src/__tests__/unit/evm/EvmUnstakeConfig.test.ts +0 -203
- package/src/__tests__/unit/fee-signature-expiration.test.ts +0 -76
- package/src/__tests__/unit/modules/CapabilityRegistry.test.ts +0 -55
- package/src/__tests__/unit/shared/BaseAction.test.ts +0 -122
- package/src/__tests__/unit/shared/BaseBtcAction.test.ts +0 -114
- package/src/__tests__/unit/solana/SolanaUnstake.test.ts +0 -314
- package/src/__tests__/unit/starknet/StarknetUnstake.test.ts +0 -318
- package/src/__tests__/unit/sui/SuiUnstake.test.ts +0 -310
- package/src/__tests__/unit/utils/satoshi.test.ts +0 -27
- package/src/__tests__/unit/validation/address-validation.test.ts +0 -350
- package/src/api-functions/generateDepositBtcAddress/generateDepositBtcAddress.stories.tsx +0 -71
- package/src/api-functions/generateDepositBtcAddress/generateDepositBtcAddress.ts +0 -235
- package/src/api-functions/generateDepositBtcAddress/index.ts +0 -1
- package/src/api-functions/get-badges-by-address/get-badges-by-address.ts +0 -13
- package/src/api-functions/get-badges-by-address/index.ts +0 -1
- package/src/api-functions/getDepositAddressReferrer/getDepositAddressReferrer.ts +0 -38
- package/src/api-functions/getDepositAddressReferrer/index.ts +0 -1
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddress.stories.tsx +0 -59
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddress.test.ts +0 -265
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddress.ts +0 -167
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddresses.stories.tsx +0 -58
- package/src/api-functions/getDepositBtcAddress/index.ts +0 -1
- package/src/api-functions/getDepositBtcAddress/make-request.ts +0 -59
- package/src/api-functions/getDepositBtcAddress/types.ts +0 -106
- package/src/api-functions/getDepositsByAddress/getDepositsByAddress.stories.tsx +0 -51
- package/src/api-functions/getDepositsByAddress/getDepositsByAddress.ts +0 -502
- package/src/api-functions/getDepositsByAddress/index.ts +0 -1
- package/src/api-functions/getLBTCExchangeRate/get-exchange-ratio.stories.tsx +0 -48
- package/src/api-functions/getLBTCExchangeRate/get-exchange-ratio.ts +0 -59
- package/src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.stories.tsx +0 -55
- package/src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.ts +0 -75
- package/src/api-functions/getLBTCExchangeRate/index.ts +0 -2
- package/src/api-functions/getNetworkFeeSignature/getNetworkFeeSignature.stories.tsx +0 -59
- package/src/api-functions/getNetworkFeeSignature/getNetworkFeeSignature.ts +0 -116
- package/src/api-functions/getNetworkFeeSignature/index.ts +0 -1
- package/src/api-functions/getPointsByAddress/getPointsByAddress.stories.tsx +0 -51
- package/src/api-functions/getPointsByAddress/getPointsByAddress.ts +0 -304
- package/src/api-functions/getPointsByAddress/index.ts +0 -1
- package/src/api-functions/getUnstakesByAddress/getUnstakesByAddress.stories.tsx +0 -51
- package/src/api-functions/getUnstakesByAddress/getUnstakesByAddress.ts +0 -368
- package/src/api-functions/getUnstakesByAddress/index.ts +0 -1
- package/src/api-functions/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +0 -70
- package/src/api-functions/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.ts +0 -91
- package/src/api-functions/getUserStakeAndBakeSignature/index.ts +0 -1
- package/src/api-functions/index.ts +0 -11
- package/src/api-functions/setReferral/index.ts +0 -1
- package/src/api-functions/setReferral/setReferral.ts +0 -67
- package/src/api-functions/storeNetworkFeeSignature/index.ts +0 -1
- package/src/api-functions/storeNetworkFeeSignature/storeNetworkFeeSignature.stories.tsx +0 -57
- package/src/api-functions/storeNetworkFeeSignature/storeNetworkFeeSignature.ts +0 -75
- package/src/api-functions/storeStakeAndBakeSignature/index.ts +0 -1
- package/src/api-functions/storeStakeAndBakeSignature/storeStakeAndBakeSignature.stories.tsx +0 -57
- package/src/api-functions/storeStakeAndBakeSignature/storeStakeAndBakeSignature.ts +0 -61
- package/src/bridge/abi/CCIP_BRIDGE_ADAPTER_ABI.json +0 -704
- package/src/bridge/abi/CCIP_ROUTER_ABI.json +0 -702
- package/src/bridge/abi/OFT_BRIDGE_ADAPTER_ABI.json +0 -912
- package/src/bridge/index.ts +0 -16
- package/src/bridge/lib/bridge.stories.tsx +0 -90
- package/src/bridge/lib/bridge.ts +0 -115
- package/src/bridge/lib/ccip-bridge.stories.tsx +0 -91
- package/src/bridge/lib/ccip-bridge.ts +0 -214
- package/src/bridge/lib/ccip-config.ts +0 -54
- package/src/bridge/lib/config.ts +0 -384
- package/src/bridge/lib/oft-bridge.stories.tsx +0 -90
- package/src/bridge/lib/oft-bridge.ts +0 -217
- package/src/chains/btc/BtcActions.ts +0 -192
- package/src/chains/btc/actions/deposit/BtcDeposit.ts +0 -388
- package/src/chains/btc/actions/deposit/config/evm.ts +0 -197
- package/src/chains/btc/actions/deposit/config/index.ts +0 -53
- package/src/chains/btc/actions/deposit/config/types.ts +0 -108
- package/src/chains/btc/actions/deposit/factory.ts +0 -53
- package/src/chains/btc/actions/deposit/index.ts +0 -23
- package/src/chains/btc/actions/deposit/types.ts +0 -120
- package/src/chains/btc/actions/depositAndDeploy/BtcDepositAndDeploy.ts +0 -366
- package/src/chains/btc/actions/depositAndDeploy/config/evm.ts +0 -105
- package/src/chains/btc/actions/depositAndDeploy/config/index.ts +0 -111
- package/src/chains/btc/actions/depositAndDeploy/config/types.ts +0 -67
- package/src/chains/btc/actions/depositAndDeploy/factory.ts +0 -38
- package/src/chains/btc/actions/depositAndDeploy/index.ts +0 -24
- package/src/chains/btc/actions/depositAndDeploy/types.ts +0 -120
- package/src/chains/btc/actions/index.ts +0 -14
- package/src/chains/btc/actions/shared/BaseBtcAction.ts +0 -495
- package/src/chains/btc/actions/shared/index.ts +0 -28
- package/src/chains/btc/actions/shared/tokenUtils.ts +0 -68
- package/src/chains/btc/actions/shared/validation.ts +0 -180
- package/src/chains/btc/actions/stake/BtcStake.ts +0 -433
- package/src/chains/btc/actions/stake/__tests__/BtcStake.test.ts +0 -247
- package/src/chains/btc/actions/stake/config/evm.ts +0 -183
- package/src/chains/btc/actions/stake/config/index.ts +0 -122
- package/src/chains/btc/actions/stake/config/solana.ts +0 -96
- package/src/chains/btc/actions/stake/config/starknet.ts +0 -66
- package/src/chains/btc/actions/stake/config/sui.ts +0 -61
- package/src/chains/btc/actions/stake/config/types.ts +0 -165
- package/src/chains/btc/actions/stake/factory.ts +0 -53
- package/src/chains/btc/actions/stake/index.ts +0 -22
- package/src/chains/btc/actions/stake/types.ts +0 -175
- package/src/chains/btc/actions/stakeAndDeploy/BtcStakeAndDeploy.ts +0 -415
- package/src/chains/btc/actions/stakeAndDeploy/config/evm.ts +0 -135
- package/src/chains/btc/actions/stakeAndDeploy/config/index.ts +0 -119
- package/src/chains/btc/actions/stakeAndDeploy/config/types.ts +0 -93
- package/src/chains/btc/actions/stakeAndDeploy/factory.ts +0 -54
- package/src/chains/btc/actions/stakeAndDeploy/index.ts +0 -26
- package/src/chains/btc/actions/stakeAndDeploy/types.ts +0 -118
- package/src/chains/btc/client/getCurrentBlockHeight.ts +0 -28
- package/src/chains/btc/client/mempool/error.ts +0 -24
- package/src/chains/btc/client/mempool/mempool.ts +0 -23
- package/src/chains/btc/index.ts +0 -71
- package/src/chains/evm/EvmActions.ts +0 -185
- package/src/chains/evm/actions/deploy/EvmDeploy.ts +0 -256
- package/src/chains/evm/actions/deploy/config/evm.ts +0 -80
- package/src/chains/evm/actions/deploy/config/index.ts +0 -8
- package/src/chains/evm/actions/deploy/config/types.ts +0 -43
- package/src/chains/evm/actions/deploy/factory.ts +0 -44
- package/src/chains/evm/actions/deploy/index.ts +0 -17
- package/src/chains/evm/actions/deploy/types.ts +0 -74
- package/src/chains/evm/actions/deposit/EvmDeposit.ts +0 -159
- package/src/chains/evm/actions/deposit/config/evm.ts +0 -100
- package/src/chains/evm/actions/deposit/config/index.ts +0 -8
- package/src/chains/evm/actions/deposit/config/types.ts +0 -39
- package/src/chains/evm/actions/deposit/factory.ts +0 -44
- package/src/chains/evm/actions/deposit/index.ts +0 -17
- package/src/chains/evm/actions/deposit/types.ts +0 -87
- package/src/chains/evm/actions/index.ts +0 -67
- package/src/chains/evm/actions/redeem/EvmRedeem.ts +0 -263
- package/src/chains/evm/actions/redeem/config/evm.ts +0 -85
- package/src/chains/evm/actions/redeem/config/index.ts +0 -8
- package/src/chains/evm/actions/redeem/config/types.ts +0 -39
- package/src/chains/evm/actions/redeem/factory.ts +0 -43
- package/src/chains/evm/actions/redeem/index.ts +0 -17
- package/src/chains/evm/actions/redeem/types.ts +0 -93
- package/src/chains/evm/actions/stake/EvmStake.ts +0 -339
- package/src/chains/evm/actions/stake/config/evm.ts +0 -89
- package/src/chains/evm/actions/stake/config/index.ts +0 -8
- package/src/chains/evm/actions/stake/config/types.ts +0 -89
- package/src/chains/evm/actions/stake/factory.ts +0 -52
- package/src/chains/evm/actions/stake/index.ts +0 -30
- package/src/chains/evm/actions/stake/types.ts +0 -104
- package/src/chains/evm/actions/unstake/EvmUnstake.ts +0 -258
- package/src/chains/evm/actions/unstake/config/evm.ts +0 -123
- package/src/chains/evm/actions/unstake/config/index.ts +0 -13
- package/src/chains/evm/actions/unstake/config/types.ts +0 -37
- package/src/chains/evm/actions/unstake/factory.ts +0 -44
- package/src/chains/evm/actions/unstake/index.ts +0 -22
- package/src/chains/evm/actions/unstake/types.ts +0 -87
- package/src/chains/evm/index.ts +0 -16
- package/src/chains/evm/shared/feeAuth.ts +0 -198
- package/src/chains/evm/shared/index.ts +0 -7
- package/src/chains/solana/SolanaActions.ts +0 -85
- package/src/chains/solana/actions/index.ts +0 -7
- package/src/chains/solana/actions/unstake/SolanaUnstake.ts +0 -151
- package/src/chains/solana/actions/unstake/config/btc.ts +0 -47
- package/src/chains/solana/actions/unstake/config/index.ts +0 -8
- package/src/chains/solana/actions/unstake/config/solana.ts +0 -47
- package/src/chains/solana/actions/unstake/config/types.ts +0 -35
- package/src/chains/solana/actions/unstake/factory.ts +0 -34
- package/src/chains/solana/actions/unstake/index.ts +0 -14
- package/src/chains/solana/actions/unstake/types.ts +0 -58
- package/src/chains/solana/index.ts +0 -8
- package/src/chains/starknet/StarknetActions.ts +0 -85
- package/src/chains/starknet/actions/index.ts +0 -7
- package/src/chains/starknet/actions/unstake/StarknetUnstake.ts +0 -128
- package/src/chains/starknet/actions/unstake/config/btc.ts +0 -43
- package/src/chains/starknet/actions/unstake/config/index.ts +0 -8
- package/src/chains/starknet/actions/unstake/config/starknet.ts +0 -43
- package/src/chains/starknet/actions/unstake/config/types.ts +0 -27
- package/src/chains/starknet/actions/unstake/factory.ts +0 -32
- package/src/chains/starknet/actions/unstake/index.ts +0 -14
- package/src/chains/starknet/actions/unstake/types.ts +0 -57
- package/src/chains/starknet/index.ts +0 -8
- package/src/chains/sui/SuiActions.ts +0 -82
- package/src/chains/sui/actions/index.ts +0 -7
- package/src/chains/sui/actions/unstake/SuiUnstake.ts +0 -146
- package/src/chains/sui/actions/unstake/config/btc.ts +0 -43
- package/src/chains/sui/actions/unstake/config/index.ts +0 -8
- package/src/chains/sui/actions/unstake/config/sui.ts +0 -43
- package/src/chains/sui/actions/unstake/config/types.ts +0 -27
- package/src/chains/sui/actions/unstake/factory.ts +0 -32
- package/src/chains/sui/actions/unstake/index.ts +0 -14
- package/src/chains/sui/actions/unstake/types.ts +0 -57
- package/src/chains/sui/index.ts +0 -8
- package/src/client/ApiNamespace.ts +0 -302
- package/src/client/AssetNamespace.ts +0 -112
- package/src/client/LombardSDK.ts +0 -212
- package/src/client/PartnerConfiguration.ts +0 -50
- package/src/client/createConfig.ts +0 -90
- package/src/client/createLombardSDK.ts +0 -130
- package/src/clients/evm-signer-adapter.ts +0 -313
- package/src/clients/public-client.ts +0 -49
- package/src/clients/rpc-url-config.ts +0 -64
- package/src/clients/wallet-client.ts +0 -34
- package/src/common/api-config.ts +0 -48
- package/src/common/blockchain-identifier.ts +0 -217
- package/src/common/chains.stories.tsx +0 -68
- package/src/common/chains.ts +0 -449
- package/src/common/constants.ts +0 -1
- package/src/common/contract-info.ts +0 -9
- package/src/common/feature-config.ts +0 -79
- package/src/common/fee-requirements.ts +0 -34
- package/src/common/parameters.ts +0 -89
- package/src/config/defaults.ts +0 -49
- package/src/config/index.ts +0 -12
- package/src/config/providers.ts +0 -81
- package/src/config/types.ts +0 -216
- package/src/config/validation.ts +0 -69
- package/src/contract-functions/approveLBTC/approveLBTC.stories.tsx +0 -79
- package/src/contract-functions/approveLBTC/approveLBTC.ts +0 -66
- package/src/contract-functions/approveLBTC/index.ts +0 -1
- package/src/contract-functions/approveToken/approveToken.ts +0 -126
- package/src/contract-functions/approveToken/index.ts +0 -1
- package/src/contract-functions/claimLBTC/claimLBTC.stories.tsx +0 -82
- package/src/contract-functions/claimLBTC/claimLBTC.ts +0 -159
- package/src/contract-functions/claimLBTC/index.ts +0 -1
- package/src/contract-functions/claimUnstakeRedeem/claimUnstakeRedeem.ts +0 -95
- package/src/contract-functions/claimUnstakeRedeem/index.ts +0 -1
- package/src/contract-functions/deposit/depositToken.stories.tsx +0 -83
- package/src/contract-functions/deposit/depositToken.ts +0 -214
- package/src/contract-functions/deposit/index.ts +0 -1
- package/src/contract-functions/getBasculeDepositStatus/decodeBasculeDepositStatus.ts +0 -170
- package/src/contract-functions/getBasculeDepositStatus/getBasculeDepositStatus.stories.tsx +0 -62
- package/src/contract-functions/getBasculeDepositStatus/getBasculeDepositStatus.ts +0 -211
- package/src/contract-functions/getBasculeDepositStatus/index.ts +0 -2
- package/src/contract-functions/getLBTCMintingFee/getLBTCMintingFee.stories.tsx +0 -61
- package/src/contract-functions/getLBTCMintingFee/getLBTCMintingFee.ts +0 -193
- package/src/contract-functions/getLBTCMintingFee/index.ts +0 -1
- package/src/contract-functions/getLBTCTotalSupply/getLBTCTotalSupply.stories.tsx +0 -51
- package/src/contract-functions/getLBTCTotalSupply/getLBTCTotalSupply.ts +0 -40
- package/src/contract-functions/getLBTCTotalSupply/index.ts +0 -1
- package/src/contract-functions/getPermitNonce/getPermitNonce.stories.tsx +0 -56
- package/src/contract-functions/getPermitNonce/getPermitNonce.ts +0 -50
- package/src/contract-functions/getPermitNonce/index.ts +0 -1
- package/src/contract-functions/getShareValue/getShareValue.stories.tsx +0 -58
- package/src/contract-functions/getShareValue/getShareValue.ts +0 -59
- package/src/contract-functions/getShareValue/index.ts +0 -1
- package/src/contract-functions/getSharesByAddress/getSharesByAddress.stories.tsx +0 -65
- package/src/contract-functions/getSharesByAddress/getSharesByAddress.ts +0 -86
- package/src/contract-functions/getSharesByAddress/index.ts +0 -4
- package/src/contract-functions/getStakeAndBakeFee/__tests__/getStakeAndBakeFee.test.ts +0 -167
- package/src/contract-functions/getStakeAndBakeFee/getStakeAndBakeFee.stories.tsx +0 -180
- package/src/contract-functions/getStakeAndBakeFee/getStakeAndBakeFee.tsx +0 -101
- package/src/contract-functions/getStakeAndBakeFee/index.ts +0 -1
- package/src/contract-functions/index.ts +0 -21
- package/src/contract-functions/signLbtcDestionationAddr/index.ts +0 -1
- package/src/contract-functions/signLbtcDestionationAddr/signLbtcDestinationAddr.ts +0 -32
- package/src/contract-functions/signLbtcDestionationAddr/signLbtcDestionationAddr.stories.tsx +0 -64
- package/src/contract-functions/signNetworkFee/getTypedData.ts +0 -41
- package/src/contract-functions/signNetworkFee/index.ts +0 -1
- package/src/contract-functions/signNetworkFee/signNetworkFee.stories.tsx +0 -94
- package/src/contract-functions/signNetworkFee/signNetworkFee.ts +0 -106
- package/src/contract-functions/signStakeAndBake/__tests__/signStakeAndBake.test.ts +0 -888
- package/src/contract-functions/signStakeAndBake/handleApprove.ts +0 -81
- package/src/contract-functions/signStakeAndBake/handlePermit.ts +0 -28
- package/src/contract-functions/signStakeAndBake/index.ts +0 -2
- package/src/contract-functions/signStakeAndBake/signStakeAndBake.stories.tsx +0 -202
- package/src/contract-functions/signStakeAndBake/signStakeAndBake.ts +0 -160
- package/src/contract-functions/signStakeAndBake/typed-data-builder.ts +0 -137
- package/src/contract-functions/signStakeAndBake/utils.ts +0 -61
- package/src/contract-functions/signStakeAndBake/validation.ts +0 -124
- package/src/contract-functions/unstakeLBTC/index.ts +0 -1
- package/src/contract-functions/unstakeLBTC/unstakeLBTC.stories.tsx +0 -92
- package/src/contract-functions/unstakeLBTC/unstakeLBTC.ts +0 -396
- package/src/contracts/abis/index.ts +0 -29
- package/src/contracts/index.ts +0 -63
- package/src/contracts/types.ts +0 -143
- package/src/contracts/utils.ts +0 -288
- package/src/core/assets/catalog.ts +0 -343
- package/src/core/assets/index.ts +0 -40
- package/src/core/assets/types.ts +0 -142
- package/src/core/assets/utils.ts +0 -287
- package/src/core/chains/catalog.ts +0 -396
- package/src/core/chains/index.ts +0 -39
- package/src/core/chains/types.ts +0 -193
- package/src/core/chains/utils.ts +0 -245
- package/src/core/index.ts +0 -72
- package/src/core/types.ts +0 -126
- package/src/debug-api/btc-script-to-address.ts +0 -20
- package/src/debug-api/btc-tx-info.ts +0 -32
- package/src/debug-api/evm-by-btc-address.ts +0 -26
- package/src/debug-api/index.ts +0 -3
- package/src/defi/README.md +0 -517
- package/src/defi/defi-registry.stories.tsx +0 -527
- package/src/defi/defi-registry.ts +0 -295
- package/src/defi/index.ts +0 -17
- package/src/index.ts +0 -336
- package/src/metrics/get-additional-rewards.ts +0 -69
- package/src/metrics/get-lbtc-apy.ts +0 -74
- package/src/metrics/get-lbtc-stats.stories.tsx +0 -57
- package/src/metrics/get-lbtc-stats.ts +0 -59
- package/src/metrics/get-positions-summary.stories.tsx +0 -58
- package/src/metrics/get-positions-summary.ts +0 -132
- package/src/modules/CapabilityRegistry.ts +0 -125
- package/src/modules/apiModule.ts +0 -51
- package/src/modules/btcModule.ts +0 -43
- package/src/modules/evmModule.ts +0 -48
- package/src/modules/index.ts +0 -60
- package/src/referrals/ReferralsClient.ts +0 -34
- package/src/referrals/index.ts +0 -1
- package/src/services/ApiService.ts +0 -152
- package/src/services/BtcService.ts +0 -29
- package/src/services/EvmService.ts +0 -127
- package/src/services/index.ts +0 -43
- package/src/shared/__tests__/errors.test.ts +0 -185
- package/src/shared/__tests__/events.test.ts +0 -120
- package/src/shared/__tests__/types.test.ts +0 -155
- package/src/shared/actions/BaseAction.ts +0 -497
- package/src/shared/actions/__tests__/BaseAction.test.ts +0 -292
- package/src/shared/actions/index.ts +0 -9
- package/src/shared/constants/statusConstants.ts +0 -108
- package/src/shared/context/ContextBuilder.ts +0 -149
- package/src/shared/context/index.ts +0 -8
- package/src/shared/context/types.ts +0 -156
- package/src/shared/deposits/depositStatus.ts +0 -402
- package/src/shared/deposits/index.ts +0 -29
- package/src/shared/errors.ts +0 -405
- package/src/shared/events.ts +0 -260
- package/src/shared/evm/switchChain.ts +0 -109
- package/src/shared/index.ts +0 -54
- package/src/shared/monitoring/__tests__/createEventEmitter.test.ts +0 -150
- package/src/shared/monitoring/createEventEmitter.ts +0 -160
- package/src/shared/monitoring/createProgressEmitter.ts +0 -46
- package/src/shared/monitoring/depositMonitor.ts +0 -211
- package/src/shared/monitoring/index.ts +0 -25
- package/src/shared/validation/index.ts +0 -411
- package/src/stories/arg-types.ts +0 -38
- package/src/stories/components/Badge.tsx +0 -27
- package/src/stories/components/Button/Button.css +0 -10
- package/src/stories/components/Button/Button.tsx +0 -52
- package/src/stories/components/Button/index.ts +0 -1
- package/src/stories/components/Card.tsx +0 -18
- package/src/stories/components/CodeBlock/CodeBlock.tsx +0 -27
- package/src/stories/components/CodeBlock/CodeBlockStyles.css +0 -3
- package/src/stories/components/CodeBlock/index.ts +0 -1
- package/src/stories/components/ConnectButton/connect-button.tsx +0 -248
- package/src/stories/components/ConnectButton/index.ts +0 -1
- package/src/stories/components/JsonPreview.tsx +0 -84
- package/src/stories/components/Spinner/Spinner.tsx +0 -27
- package/src/stories/components/Spinner/index.ts +0 -1
- package/src/stories/components/StatsCard.tsx +0 -30
- package/src/stories/components/StatusIndicator.tsx +0 -37
- package/src/stories/components/TreeNode.tsx +0 -47
- package/src/stories/components/decorators/function-type.tsx +0 -63
- package/src/stories/components/decorators/index.ts +0 -2
- package/src/stories/components/decorators/wagmi-decorator.tsx +0 -92
- package/src/stories/components/error-block.tsx +0 -21
- package/src/stories/components/index.ts +0 -11
- package/src/stories/constants.ts +0 -3
- package/src/stories/hooks/useConnection.ts +0 -63
- package/src/stories/hooks/useQuery.ts +0 -57
- package/src/tokens/__tests__/token-addresses.test.ts +0 -551
- package/src/tokens/abi/ASSET_ROUTER_ABI.ts +0 -1966
- package/src/tokens/abi/BRIDGE_TOKEN_ADAPTER_ABI.ts +0 -1405
- package/src/tokens/abi/BTCK_ABI.ts +0 -1092
- package/src/tokens/abi/KATANA_BASCULE_ABI.ts +0 -653
- package/src/tokens/abi/LBTC_ABI.json +0 -1761
- package/src/tokens/abi/LBTC_ABI.ts +0 -1761
- package/src/tokens/abi/LBTC_BASCULE_ABI.json +0 -850
- package/src/tokens/abi/NATIVE_LBTC_ABI.ts +0 -1147
- package/src/tokens/abi/STLBTC_ABI.ts +0 -1062
- package/src/tokens/cross-chain-addresses.stories.tsx +0 -236
- package/src/tokens/denomination-utils.stories.tsx +0 -176
- package/src/tokens/getLbtcContractAddresses.stories.tsx +0 -158
- package/src/tokens/getTokenByAddress.stories.tsx +0 -172
- package/src/tokens/getTokenContractInfo.stories.tsx +0 -148
- package/src/tokens/getTokenInfo.stories.tsx +0 -133
- package/src/tokens/isUpgradedContract.stories.tsx +0 -124
- package/src/tokens/lbtc-addresses.ts +0 -18
- package/src/tokens/token-addresses.ts +0 -477
- package/src/tokens/tokens.ts +0 -249
- package/src/tokens/types.ts +0 -80
- package/src/utils/array.ts +0 -31
- package/src/utils/block.ts +0 -23
- package/src/utils/chain.ts +0 -152
- package/src/utils/consoleLogger.ts +0 -140
- package/src/utils/ensureNotSanctionedAddress.ts +0 -11
- package/src/utils/env.ts +0 -20
- package/src/utils/err.ts +0 -83
- package/src/utils/evmAccount.ts +0 -47
- package/src/utils/gas.ts +0 -36
- package/src/utils/hex.ts +0 -9
- package/src/utils/http.ts +0 -224
- package/src/utils/numbers.ts +0 -37
- package/src/utils/pagination.ts +0 -70
- package/src/utils/satoshi.ts +0 -41
- package/src/utils/time.ts +0 -12
- package/src/utils/transaction-executor.ts +0 -299
- package/src/vaults/abi/SILO_VAULT_SPENDER_ABI.json +0 -793
- package/src/vaults/abi/VEDA_VAULT_ABI.json +0 -452
- package/src/vaults/abi/VEDA_VAULT_ACCOUNTANT_ABI.json +0 -591
- package/src/vaults/abi/VEDA_VAULT_BASE_ASSET_ABI.json +0 -296
- package/src/vaults/abi/VEDA_VAULT_BORING_WITHDRAW_QUEUE_ABI.json +0 -502
- package/src/vaults/abi/VEDA_VAULT_LENS_ABI.json +0 -175
- package/src/vaults/abi/VEDA_VAULT_SPENDER_ABI.json +0 -408
- package/src/vaults/abi/VEDA_VAULT_TELLER_ABI.json +0 -700
- package/src/vaults/abi/index.ts +0 -4
- package/src/vaults/index.ts +0 -46
- package/src/vaults/lib/config.ts +0 -184
- package/src/vaults/lib/metrics/get-vault-apy.stories.tsx +0 -58
- package/src/vaults/lib/metrics/get-vault-apy.ts +0 -176
- package/src/vaults/lib/metrics/get-vault-points.stories.tsx +0 -60
- package/src/vaults/lib/metrics/get-vault-points.ts +0 -74
- package/src/vaults/lib/metrics/get-vault-tvl.stories.tsx +0 -58
- package/src/vaults/lib/metrics/get-vault-tvl.ts +0 -121
- package/src/vaults/lib/ops/cancel-withdraw.stories.tsx +0 -80
- package/src/vaults/lib/ops/deposit.stories.tsx +0 -82
- package/src/vaults/lib/ops/deposit.ts +0 -152
- package/src/vaults/lib/ops/get-vault-deposits.stories.tsx +0 -65
- package/src/vaults/lib/ops/get-vault-deposits.ts +0 -209
- package/src/vaults/lib/ops/get-vault-withdrawals.stories.tsx +0 -67
- package/src/vaults/lib/ops/get-vault-withdrawals.ts +0 -349
- package/src/vaults/lib/ops/withdraw.stories.tsx +0 -82
- package/src/vaults/lib/ops/withdraw.ts +0 -225
- package/src/version.ts +0 -56
- package/src/vite-env.d.ts +0 -1
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { decodeFunctionData, encodeAbiParameters, keccak256 } from 'viem';
|
|
2
|
-
|
|
3
|
-
const GMP_V1_SELECTOR = '0xe288fb4a';
|
|
4
|
-
const MINT_SELECTOR = '0x155b6b13';
|
|
5
|
-
|
|
6
|
-
// ABI for the outer payload (matches your Solidity encodePayload/MessageV1)
|
|
7
|
-
const gmpPayloadAbi = {
|
|
8
|
-
type: 'function',
|
|
9
|
-
name: 'MessageV1',
|
|
10
|
-
inputs: [
|
|
11
|
-
{ name: 'msgPath', type: 'bytes32' },
|
|
12
|
-
{ name: 'msgNonce', type: 'uint256' },
|
|
13
|
-
{ name: 'msgSender', type: 'bytes32' },
|
|
14
|
-
{ name: 'msgRecipient', type: 'bytes32' },
|
|
15
|
-
{ name: 'msgDestinationCaller', type: 'bytes32' },
|
|
16
|
-
{ name: 'msgBody', type: 'bytes' },
|
|
17
|
-
],
|
|
18
|
-
} as const;
|
|
19
|
-
|
|
20
|
-
// ABI for the inner body (mint)
|
|
21
|
-
const mintAbi = {
|
|
22
|
-
type: 'function',
|
|
23
|
-
name: 'mint',
|
|
24
|
-
inputs: [
|
|
25
|
-
{ name: 'toToken', type: 'bytes32' },
|
|
26
|
-
{ name: 'recipient', type: 'bytes32' },
|
|
27
|
-
{ name: 'amount', type: 'uint256' },
|
|
28
|
-
],
|
|
29
|
-
} as const;
|
|
30
|
-
|
|
31
|
-
export interface DecodedMintBody {
|
|
32
|
-
selector: string;
|
|
33
|
-
toToken: string;
|
|
34
|
-
recipient: string;
|
|
35
|
-
amount: bigint;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface DecodedGmpPayload {
|
|
39
|
-
selector: string; // outer selector (GMP_V1_SELECTOR)
|
|
40
|
-
msgPath: string;
|
|
41
|
-
msgNonce: bigint;
|
|
42
|
-
msgSender: string;
|
|
43
|
-
msgRecipient: string;
|
|
44
|
-
msgDestinationCaller: string;
|
|
45
|
-
rawBody: string; // full hex of msgBody
|
|
46
|
-
mint: DecodedMintBody; // decoded body
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Example usage (for testing/debugging):
|
|
51
|
-
*
|
|
52
|
-
* async function testDecoding() {
|
|
53
|
-
* const res = decodeGmpMintPayload(
|
|
54
|
-
* '0xe288fb4a022d9999f6a62cd3401ba6e03ae710a1b3fcd8a77325b435371108676e600a5f...',
|
|
55
|
-
* );
|
|
56
|
-
* console.log(res);
|
|
57
|
-
* const mintID = calcMintIDFromDecoded(res, 747474); // Katana chainId
|
|
58
|
-
* console.log(mintID);
|
|
59
|
-
* }
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Decode ABI-encoded GMP Payload hex where msgBody is an ABI-encoded `mint` call.
|
|
64
|
-
*/
|
|
65
|
-
export function decodeGmpMintPayload(hexData: string): DecodedGmpPayload {
|
|
66
|
-
if (!hexData.startsWith('0x')) {
|
|
67
|
-
throw new Error('Payload must be 0x-prefixed hex');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 1) Check outer selector
|
|
71
|
-
const selector = hexData.slice(0, 10); // 4 bytes = 8 hex chars + '0x'
|
|
72
|
-
if (selector.toLowerCase() !== GMP_V1_SELECTOR.toLowerCase()) {
|
|
73
|
-
throw new Error(
|
|
74
|
-
`Invalid GMP selector: expected ${GMP_V1_SELECTOR}, got ${selector}`,
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// 2) Decode outer payload using viem
|
|
79
|
-
const decoded = decodeFunctionData({
|
|
80
|
-
abi: [gmpPayloadAbi],
|
|
81
|
-
data: hexData as `0x${string}`,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (!decoded.args) {
|
|
85
|
-
throw new Error('Failed to decode GMP payload: args is undefined');
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const msgPath = decoded.args[0] as string;
|
|
89
|
-
const msgNonce = decoded.args[1] as bigint;
|
|
90
|
-
const msgSender = decoded.args[2] as string;
|
|
91
|
-
const msgRecipient = decoded.args[3] as string;
|
|
92
|
-
const msgDestinationCaller = decoded.args[4] as string;
|
|
93
|
-
const msgBody = decoded.args[5] as string; // bytes => 0x…
|
|
94
|
-
|
|
95
|
-
if (typeof msgBody !== 'string' || !msgBody.startsWith('0x')) {
|
|
96
|
-
throw new Error('msgBody is not valid hex');
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// 3) Check inner selector (mint)
|
|
100
|
-
const bodySelector = msgBody.slice(0, 10);
|
|
101
|
-
if (bodySelector.toLowerCase() !== MINT_SELECTOR.toLowerCase()) {
|
|
102
|
-
throw new Error(
|
|
103
|
-
`Invalid mint selector in body: expected ${MINT_SELECTOR}, got ${bodySelector}`,
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// 4) Decode mint body using viem
|
|
108
|
-
const mintDecoded = decodeFunctionData({
|
|
109
|
-
abi: [mintAbi],
|
|
110
|
-
data: msgBody as `0x${string}`,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
if (!mintDecoded.args) {
|
|
114
|
-
throw new Error('Failed to decode mint body: args is undefined');
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const toToken = mintDecoded.args[0] as string;
|
|
118
|
-
const recipient = mintDecoded.args[1] as string;
|
|
119
|
-
const amount = mintDecoded.args[2] as bigint;
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
selector,
|
|
123
|
-
msgPath,
|
|
124
|
-
msgNonce,
|
|
125
|
-
msgSender,
|
|
126
|
-
msgRecipient,
|
|
127
|
-
msgDestinationCaller,
|
|
128
|
-
rawBody: msgBody,
|
|
129
|
-
mint: {
|
|
130
|
-
selector: bodySelector,
|
|
131
|
-
toToken,
|
|
132
|
-
recipient,
|
|
133
|
-
amount,
|
|
134
|
-
},
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Calculate mintID off-chain, equivalent to Solidity _mintID(Message).
|
|
140
|
-
*
|
|
141
|
-
* @param decoded - result of decodeGmpMintPayload(...)
|
|
142
|
-
* @param chainId - destination EVM chain id (same as block.chainid on that chain)
|
|
143
|
-
*/
|
|
144
|
-
export function calcMintIDFromDecoded(
|
|
145
|
-
decoded: DecodedGmpPayload,
|
|
146
|
-
chainId: bigint | number | string,
|
|
147
|
-
): string {
|
|
148
|
-
const { msgNonce, mint } = decoded;
|
|
149
|
-
|
|
150
|
-
// Solidity: abi.encode(uint256 nonce, uint256 chainId, address recipient, address toToken, uint256 amount)
|
|
151
|
-
const encoded = encodeAbiParameters(
|
|
152
|
-
[
|
|
153
|
-
{ name: 'nonce', type: 'uint256' },
|
|
154
|
-
{ name: 'chainId', type: 'uint256' },
|
|
155
|
-
{ name: 'recipient', type: 'bytes32' },
|
|
156
|
-
{ name: 'toToken', type: 'bytes32' },
|
|
157
|
-
{ name: 'amount', type: 'uint256' },
|
|
158
|
-
],
|
|
159
|
-
[
|
|
160
|
-
BigInt(msgNonce), // self.nonce
|
|
161
|
-
BigInt(chainId), // block.chainid
|
|
162
|
-
mint.recipient as `0x${string}`, // self.recipient
|
|
163
|
-
mint.toToken as `0x${string}`, // self.toToken
|
|
164
|
-
BigInt(mint.amount), // self.amount
|
|
165
|
-
],
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
// bytes32 mintID = keccak256(encoded)
|
|
169
|
-
return keccak256(encoded);
|
|
170
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { ChainId } from '../../common/chains';
|
|
4
|
-
import {
|
|
5
|
-
chainSelector,
|
|
6
|
-
envSelector,
|
|
7
|
-
makeTokenSelector,
|
|
8
|
-
} from '../../stories/arg-types';
|
|
9
|
-
import { Button } from '../../stories/components/Button';
|
|
10
|
-
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
11
|
-
import { functionType } from '../../stories/components/decorators';
|
|
12
|
-
import useQuery from '../../stories/hooks/useQuery';
|
|
13
|
-
import { Token } from '../../tokens/token-addresses';
|
|
14
|
-
import {
|
|
15
|
-
getBasculeDepositStatus,
|
|
16
|
-
IGetBasculeDepositStatusParameters,
|
|
17
|
-
} from './getBasculeDepositStatus';
|
|
18
|
-
|
|
19
|
-
const meta = {
|
|
20
|
-
title: 'read/getBasculeDepositStatus',
|
|
21
|
-
component: StoryView,
|
|
22
|
-
tags: ['autodocs'],
|
|
23
|
-
decorators: [functionType('read')],
|
|
24
|
-
argTypes: {
|
|
25
|
-
...chainSelector,
|
|
26
|
-
...envSelector,
|
|
27
|
-
...makeTokenSelector([Token.LBTC, Token.BTCb, Token.BTCK]),
|
|
28
|
-
},
|
|
29
|
-
} satisfies Meta<typeof StoryView>;
|
|
30
|
-
|
|
31
|
-
export default meta;
|
|
32
|
-
|
|
33
|
-
type Story = StoryObj<typeof meta>;
|
|
34
|
-
|
|
35
|
-
export const WithParams: Story = {
|
|
36
|
-
args: {
|
|
37
|
-
rawPayload:
|
|
38
|
-
'e288fb4a022d9999f6a62cd3401ba6e03ae710a1b3fcd8a77325b435371108676e600a5f000000000000000000000000000000000000000000000000000000000000002200000000000000000000000089e3e4e7a699d6f131d893aeef7ee143706ac23a0000000000000000000000009ece5fb1ab62d9075c4ec814b321e24d8ea021ac000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000064155b6b13000000000000000000000000ecac9c5f704e954931349da37f60e39f515c11c1000000000000000000000000659579f1460c38c3ce3288b47b074646cef855fc0000000000000000000000000000000000000000000000000000000000004df800000000000000000000000000000000000000000000000000000000',
|
|
39
|
-
chainId: ChainId.katana,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export function StoryView(props: IGetBasculeDepositStatusParameters) {
|
|
44
|
-
const request = async () => {
|
|
45
|
-
return getBasculeDepositStatus(props);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const { data, error, isLoading, refetch } = useQuery(request, [], false);
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<>
|
|
52
|
-
<Button
|
|
53
|
-
onClick={refetch}
|
|
54
|
-
disabled={isLoading}
|
|
55
|
-
isLoading={isLoading}
|
|
56
|
-
actionName={getBasculeDepositStatus.name}
|
|
57
|
-
/>
|
|
58
|
-
|
|
59
|
-
<CodeBlock text={error || data} />
|
|
60
|
-
</>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_ENV } from '@lombard.finance/sdk-common';
|
|
2
|
-
import {
|
|
3
|
-
Address,
|
|
4
|
-
ByteArray,
|
|
5
|
-
Client,
|
|
6
|
-
getContract,
|
|
7
|
-
keccak256,
|
|
8
|
-
PublicClient,
|
|
9
|
-
zeroAddress,
|
|
10
|
-
} from 'viem';
|
|
11
|
-
|
|
12
|
-
import { Deposit } from '../../api-functions/getDepositsByAddress/getDepositsByAddress';
|
|
13
|
-
import { makePublicClient } from '../../clients/public-client';
|
|
14
|
-
import { makeWalletClient } from '../../clients/wallet-client';
|
|
15
|
-
import {
|
|
16
|
-
isEthereumChain,
|
|
17
|
-
isKatanaChain,
|
|
18
|
-
isMegaethChain,
|
|
19
|
-
isMonadChain,
|
|
20
|
-
isStableChain,
|
|
21
|
-
} from '../../common/chains';
|
|
22
|
-
import { CommonOptionalWriteParameters } from '../../common/parameters';
|
|
23
|
-
import ASSET_ROUTER_ABI from '../../tokens/abi/ASSET_ROUTER_ABI';
|
|
24
|
-
import KATANA_BASCULE_ABI from '../../tokens/abi/KATANA_BASCULE_ABI';
|
|
25
|
-
import LBTC_BASCULE_ABI from '../../tokens/abi/LBTC_BASCULE_ABI.json';
|
|
26
|
-
import { AddressKind, Token } from '../../tokens/token-addresses';
|
|
27
|
-
import { getTokenContractInfo, isUpgradedAbi } from '../../tokens/tokens';
|
|
28
|
-
import { getErrorMessage } from '../../utils/err';
|
|
29
|
-
import {
|
|
30
|
-
calcMintIDFromDecoded,
|
|
31
|
-
decodeGmpMintPayload,
|
|
32
|
-
} from './decodeBasculeDepositStatus';
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The bascule drawbridge deposit status.
|
|
36
|
-
*/
|
|
37
|
-
export enum BasculeDepositStatus {
|
|
38
|
-
/**
|
|
39
|
-
* The value representing that the deposit is unreported or potentially
|
|
40
|
-
* still pending.
|
|
41
|
-
*/
|
|
42
|
-
UNREPORTED = 0,
|
|
43
|
-
/**
|
|
44
|
-
* The value representing that the deposit is reported.
|
|
45
|
-
*/
|
|
46
|
-
REPORTED = 1,
|
|
47
|
-
/**
|
|
48
|
-
* The value representing that the deposit has already been withdrawn.
|
|
49
|
-
*/
|
|
50
|
-
WITHDRAWN = 2,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface IGetBasculeDepositStatusParameters
|
|
54
|
-
extends CommonOptionalWriteParameters {
|
|
55
|
-
/**
|
|
56
|
-
* The deposit for which the bascule status will be checked.
|
|
57
|
-
* You can omit `rawPayload` parameter if `deposit` is provided.
|
|
58
|
-
*/
|
|
59
|
-
deposit?: Deposit;
|
|
60
|
-
/**
|
|
61
|
-
* The `rawPayload` of the deposit for which the bascule status
|
|
62
|
-
* will be checked.
|
|
63
|
-
* You can omit `deposit` parameter if `rawPayload` is provided.
|
|
64
|
-
*/
|
|
65
|
-
rawPayload?: string;
|
|
66
|
-
token?: Token;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Gets the Bascule drawbridge deposit status for given deposit.
|
|
71
|
-
*
|
|
72
|
-
* **Multiple Bascule Interfaces:**
|
|
73
|
-
* This function supports two different bascule contract interfaces:
|
|
74
|
-
* - **Asset Router (upgraded)**: Uses `bascule()` getter - for StakedLBTC and upgraded contracts
|
|
75
|
-
* - **Bridge Token Adapter**: Uses `getBascule()` getter - for BTCb on Avalanche
|
|
76
|
-
* - **Legacy NativeLBTC**: Uses `Bascule()` getter - for old LBTC contracts
|
|
77
|
-
*
|
|
78
|
-
* **MintID Calculation:**
|
|
79
|
-
* For Katana chains, this function uses proper GMP payload decoding to calculate
|
|
80
|
-
* the mintID, which matches the Solidity implementation. For other chains, it uses
|
|
81
|
-
* a simplified method.
|
|
82
|
-
*
|
|
83
|
-
* @param {IGetBasculeDepositStatusParameters} parameters - The parameters.
|
|
84
|
-
* @param {Deposit} parameters.deposit - The deposit for which the bascule status will be checked. You can omit `rawPayload` parameter if `deposit` is provided.
|
|
85
|
-
* @param {string} parameters.rawPayload - The `rawPayload` of the deposit for which the bascule status will be checked. You can omit `deposit` parameter if `rawPayload` is provided.
|
|
86
|
-
* @param {ChainId} parameters.chainId - The chain id. For Katana chains (Katana mainnet or Katana Tatara testnet), GMP payload decoding is used.
|
|
87
|
-
* @param {Token} parameters.token - The token for which to check bascule status. Defaults to Token.LBTC.
|
|
88
|
-
* @param {EIP1193Provider} parameters.provider - The optional EIP1193 provider.
|
|
89
|
-
* @param {string} parameters.rpcUrl - The optional rpc url.
|
|
90
|
-
* @param {Env} parameters.env - The optional environment identifier.
|
|
91
|
-
*
|
|
92
|
-
* @returns {Promise<BasculeDepositStatus>}
|
|
93
|
-
*/
|
|
94
|
-
export async function getBasculeDepositStatus({
|
|
95
|
-
deposit,
|
|
96
|
-
rawPayload,
|
|
97
|
-
provider,
|
|
98
|
-
chainId,
|
|
99
|
-
rpcUrl,
|
|
100
|
-
env = DEFAULT_ENV,
|
|
101
|
-
token = Token.LBTC,
|
|
102
|
-
}: IGetBasculeDepositStatusParameters) {
|
|
103
|
-
const payload = deposit?.rawPayload || rawPayload;
|
|
104
|
-
|
|
105
|
-
if (!payload) {
|
|
106
|
-
throw new Error(
|
|
107
|
-
"No 'rawPayload' or 'deposit' data provided. Please provide 'rawPayload' or 'deposit' parameter.",
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const publicClient = makePublicClient({ chainId, rpcUrl, env });
|
|
112
|
-
const tokenContractInfo = await getTokenContractInfo(
|
|
113
|
-
token,
|
|
114
|
-
chainId,
|
|
115
|
-
env,
|
|
116
|
-
AddressKind.Adapter,
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
// Determine which bascule getter function to use based on the contract type
|
|
120
|
-
// There are two different approaches:
|
|
121
|
-
// 1. Upgraded contracts (Asset Router): token.getAssetRouter() -> assetRouter.bascule()
|
|
122
|
-
// 2. Legacy contracts (NativeLBTC): Bascule()
|
|
123
|
-
|
|
124
|
-
let basculeContractAddress: Address;
|
|
125
|
-
|
|
126
|
-
if (isUpgradedAbi(tokenContractInfo.abi) && token === Token.LBTC) {
|
|
127
|
-
// Upgraded contract - get bascule from Asset Router
|
|
128
|
-
const assetRouterAddress = (await publicClient.readContract({
|
|
129
|
-
abi: tokenContractInfo.abi,
|
|
130
|
-
address: tokenContractInfo.address,
|
|
131
|
-
functionName: 'getAssetRouter',
|
|
132
|
-
})) as Address;
|
|
133
|
-
|
|
134
|
-
basculeContractAddress = (await publicClient.readContract({
|
|
135
|
-
abi: ASSET_ROUTER_ABI,
|
|
136
|
-
address: assetRouterAddress,
|
|
137
|
-
functionName: 'bascule',
|
|
138
|
-
})) as Address;
|
|
139
|
-
} else {
|
|
140
|
-
basculeContractAddress = (await publicClient.readContract({
|
|
141
|
-
abi: tokenContractInfo.abi,
|
|
142
|
-
address: tokenContractInfo.address,
|
|
143
|
-
functionName: 'Bascule',
|
|
144
|
-
})) as Address;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// If there's no bascule contract address on the LBTC contract then return
|
|
148
|
-
// the the deposit is ok (REPORTED).
|
|
149
|
-
if (basculeContractAddress === zeroAddress) {
|
|
150
|
-
return BasculeDepositStatus.REPORTED;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
let client: PublicClient | Client | undefined = undefined;
|
|
154
|
-
if (!provider) {
|
|
155
|
-
client = makePublicClient({ chainId, rpcUrl });
|
|
156
|
-
} else {
|
|
157
|
-
client = makeWalletClient({ provider, chainId });
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (!client) {
|
|
161
|
-
throw new Error(
|
|
162
|
-
"Could not determine the client for the contract interactions. Please provide the 'provider' and 'chainId' parameters or 'chainId' and optionally the 'rpcUrl' parameter.",
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const shouldCheckMintHistory =
|
|
167
|
-
(isKatanaChain(chainId) ||
|
|
168
|
-
isMonadChain(chainId) ||
|
|
169
|
-
isEthereumChain(chainId) ||
|
|
170
|
-
isStableChain(chainId) ||
|
|
171
|
-
isMegaethChain(chainId)) &&
|
|
172
|
-
token === Token.LBTC;
|
|
173
|
-
|
|
174
|
-
try {
|
|
175
|
-
// For Katana chains, use proper GMP payload decoding to calculate mintID
|
|
176
|
-
if (shouldCheckMintHistory) {
|
|
177
|
-
const prefixedPayload = payload.startsWith('0x')
|
|
178
|
-
? payload
|
|
179
|
-
: `0x${payload}`;
|
|
180
|
-
const decoded = decodeGmpMintPayload(prefixedPayload);
|
|
181
|
-
const mintId = calcMintIDFromDecoded(decoded, chainId);
|
|
182
|
-
|
|
183
|
-
const [, status] = (await publicClient.readContract({
|
|
184
|
-
abi: KATANA_BASCULE_ABI,
|
|
185
|
-
address: basculeContractAddress,
|
|
186
|
-
functionName: 'mintHistory',
|
|
187
|
-
args: [mintId],
|
|
188
|
-
})) as [unknown, BasculeDepositStatus];
|
|
189
|
-
|
|
190
|
-
return status;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// For non-Katana chains, use the simple method
|
|
194
|
-
const basculeDepositId = keccak256(
|
|
195
|
-
Buffer.from(payload.slice(8), 'hex') as unknown as ByteArray,
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
const basculeContract = getContract({
|
|
199
|
-
abi: LBTC_BASCULE_ABI,
|
|
200
|
-
address: basculeContractAddress,
|
|
201
|
-
client: publicClient,
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
const status = await basculeContract.read.depositHistory([
|
|
205
|
-
basculeDepositId,
|
|
206
|
-
]);
|
|
207
|
-
return status as BasculeDepositStatus;
|
|
208
|
-
} catch (err) {
|
|
209
|
-
throw new Error(getErrorMessage(err));
|
|
210
|
-
}
|
|
211
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { ChainId } from '../../common/chains';
|
|
4
|
-
import { chainSelector, envSelector } from '../../stories/arg-types';
|
|
5
|
-
import { Button } from '../../stories/components/Button';
|
|
6
|
-
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
7
|
-
import { functionType } from '../../stories/components/decorators';
|
|
8
|
-
import useQuery from '../../stories/hooks/useQuery';
|
|
9
|
-
import { getLBTCMintingFee } from './getLBTCMintingFee';
|
|
10
|
-
|
|
11
|
-
const meta = {
|
|
12
|
-
title: 'read/getLBTCMintingFee',
|
|
13
|
-
component: StoryView,
|
|
14
|
-
tags: ['autodocs'],
|
|
15
|
-
decorators: [functionType('read')],
|
|
16
|
-
argTypes: { ...chainSelector, ...envSelector },
|
|
17
|
-
} satisfies Meta<typeof StoryView>;
|
|
18
|
-
|
|
19
|
-
export default meta;
|
|
20
|
-
|
|
21
|
-
type Story = StoryObj<typeof meta>;
|
|
22
|
-
|
|
23
|
-
export const Holesky: Story = {
|
|
24
|
-
args: {
|
|
25
|
-
chainId: ChainId.holesky,
|
|
26
|
-
env: undefined,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
type Params = Parameters<typeof getLBTCMintingFee>[0];
|
|
31
|
-
|
|
32
|
-
export function StoryView(props: Params) {
|
|
33
|
-
const request = async () => {
|
|
34
|
-
return getLBTCMintingFee({
|
|
35
|
-
chainId: props.chainId,
|
|
36
|
-
env: props.env,
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const { data, error, isLoading, refetch } = useQuery(request, [], false);
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<div>
|
|
44
|
-
<Button
|
|
45
|
-
onClick={refetch}
|
|
46
|
-
disabled={isLoading}
|
|
47
|
-
isLoading={isLoading}
|
|
48
|
-
actionName={getLBTCMintingFee.name}
|
|
49
|
-
/>
|
|
50
|
-
|
|
51
|
-
<CodeBlock text={error || data?.toFormat()} />
|
|
52
|
-
|
|
53
|
-
{data && (
|
|
54
|
-
<div className="mt-4 p-4 border rounded">
|
|
55
|
-
<h3 className="text-lg font-bold mb-2">Fee Details</h3>
|
|
56
|
-
<p>Minting Fee: {data.toFormat()} BTC</p>
|
|
57
|
-
</div>
|
|
58
|
-
)}
|
|
59
|
-
</div>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import BigNumber from 'bignumber.js';
|
|
2
|
-
|
|
3
|
-
import { makePublicClient } from '../../clients/public-client';
|
|
4
|
-
import { CommonParameters } from '../../common/parameters';
|
|
5
|
-
import ASSET_ROUTER_ABI from '../../tokens/abi/ASSET_ROUTER_ABI';
|
|
6
|
-
import { AddressKind, Token } from '../../tokens/token-addresses';
|
|
7
|
-
import { getTokenContractInfo, isUpgradedAbi } from '../../tokens/tokens';
|
|
8
|
-
import { determineEnv } from '../../utils/env';
|
|
9
|
-
import { fromSatoshi } from '../../utils/satoshi';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Gets LBTC minting fee amount.
|
|
13
|
-
*
|
|
14
|
-
* @param {CommonParameters} parameters - The parameters.
|
|
15
|
-
* @param {ChainId} parameters.chainId - The chain id.
|
|
16
|
-
* @param {string} parameters.rpcUrl - The optional rpc url.
|
|
17
|
-
* @param {Env} parameters.env - The optional environment identifier.
|
|
18
|
-
*
|
|
19
|
-
* @return {Promise<BigNumber>}
|
|
20
|
-
*/
|
|
21
|
-
export async function getLBTCMintingFee(
|
|
22
|
-
props: CommonParameters,
|
|
23
|
-
): Promise<BigNumber> {
|
|
24
|
-
return getMintingFee({ token: Token.LBTC, ...props });
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Gets LBTC burn commission (fee) amount. */
|
|
28
|
-
export async function getLBTCBurningFee(props: CommonParameters) {
|
|
29
|
-
return getRedeemFee({ token: Token.LBTC, ...props });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function getMintingFee({
|
|
33
|
-
token,
|
|
34
|
-
chainId,
|
|
35
|
-
rpcUrl,
|
|
36
|
-
env,
|
|
37
|
-
}: { token: Token } & CommonParameters) {
|
|
38
|
-
if (![Token.LBTC, Token.BTCK, Token.BTCb].includes(token)) {
|
|
39
|
-
throw new Error(`Unsupported token: ${token}`);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const environment = env || determineEnv(chainId);
|
|
43
|
-
|
|
44
|
-
const publicClient = makePublicClient({ chainId, rpcUrl, env: environment });
|
|
45
|
-
const tokenContract = await getTokenContractInfo(
|
|
46
|
-
token,
|
|
47
|
-
chainId,
|
|
48
|
-
environment,
|
|
49
|
-
AddressKind.Adapter,
|
|
50
|
-
);
|
|
51
|
-
const tokenContractAbi = tokenContract.abi;
|
|
52
|
-
|
|
53
|
-
let rawFeeValue = 0n;
|
|
54
|
-
|
|
55
|
-
if (isUpgradedAbi(tokenContractAbi) || token === Token.BTCb) {
|
|
56
|
-
const assetRouterAddress = await publicClient.readContract({
|
|
57
|
-
abi: tokenContractAbi,
|
|
58
|
-
address: tokenContract.address,
|
|
59
|
-
functionName: 'getAssetRouter',
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const assetRouter = {
|
|
63
|
-
abi: ASSET_ROUTER_ABI,
|
|
64
|
-
address: assetRouterAddress,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
rawFeeValue = (await publicClient.readContract({
|
|
68
|
-
abi: assetRouter.abi,
|
|
69
|
-
address: assetRouter.address,
|
|
70
|
-
functionName: 'maxMintCommission',
|
|
71
|
-
args: [tokenContract.address],
|
|
72
|
-
})) as bigint;
|
|
73
|
-
} else {
|
|
74
|
-
rawFeeValue = await publicClient.readContract({
|
|
75
|
-
abi: tokenContract.abi,
|
|
76
|
-
address: tokenContract.address,
|
|
77
|
-
functionName: 'getMintFee',
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return fromSatoshi(String(rawFeeValue));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export async function getRedeemFee({
|
|
85
|
-
token,
|
|
86
|
-
chainId,
|
|
87
|
-
rpcUrl,
|
|
88
|
-
env,
|
|
89
|
-
}: { token: Token } & CommonParameters) {
|
|
90
|
-
if (![Token.LBTC, Token.BTCK, Token.BTCb].includes(token)) {
|
|
91
|
-
throw new Error(`Unsupported token: ${token}`);
|
|
92
|
-
}
|
|
93
|
-
const environment = env || determineEnv(chainId);
|
|
94
|
-
|
|
95
|
-
const publicClient = makePublicClient({ chainId, rpcUrl, env: environment });
|
|
96
|
-
const tokenContract = await getTokenContractInfo(
|
|
97
|
-
token,
|
|
98
|
-
chainId,
|
|
99
|
-
environment,
|
|
100
|
-
AddressKind.Adapter,
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
let rawFeeValue = 0n;
|
|
104
|
-
if (isUpgradedAbi(tokenContract.abi) || token === Token.BTCb) {
|
|
105
|
-
const assetRouterAddress = await publicClient.readContract({
|
|
106
|
-
abi: tokenContract.abi,
|
|
107
|
-
address: tokenContract.address,
|
|
108
|
-
functionName: 'getAssetRouter',
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const assetRouter = {
|
|
112
|
-
abi: ASSET_ROUTER_ABI,
|
|
113
|
-
address: assetRouterAddress,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// 1.
|
|
117
|
-
const toNativeCommissionValue = (await publicClient.readContract({
|
|
118
|
-
abi: assetRouter.abi,
|
|
119
|
-
address: assetRouter.address,
|
|
120
|
-
functionName: 'toNativeCommission',
|
|
121
|
-
args: [tokenContract.address],
|
|
122
|
-
})) as bigint;
|
|
123
|
-
|
|
124
|
-
// 2.
|
|
125
|
-
const [redeemFeeValue /* redeemForBtcMinAmountValue, isRedeemEnabled */] =
|
|
126
|
-
(await publicClient.readContract({
|
|
127
|
-
abi: assetRouter.abi,
|
|
128
|
-
address: assetRouter.address,
|
|
129
|
-
functionName: 'tokenConfig',
|
|
130
|
-
args: [tokenContract.address],
|
|
131
|
-
})) as [bigint];
|
|
132
|
-
|
|
133
|
-
rawFeeValue = toNativeCommissionValue + redeemFeeValue;
|
|
134
|
-
} else {
|
|
135
|
-
// legacy (and BTCK v1)
|
|
136
|
-
rawFeeValue = await publicClient.readContract({
|
|
137
|
-
abi: tokenContract.abi,
|
|
138
|
-
address: tokenContract.address,
|
|
139
|
-
functionName: 'getBurnCommission',
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return fromSatoshi(String(rawFeeValue));
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export async function getMinRedeemAmount({
|
|
147
|
-
token,
|
|
148
|
-
chainId,
|
|
149
|
-
rpcUrl,
|
|
150
|
-
env,
|
|
151
|
-
}: { token: Token } & CommonParameters) {
|
|
152
|
-
if (![Token.LBTC, Token.BTCK, Token.BTCb].includes(token)) {
|
|
153
|
-
throw new Error(`Unsupported token: ${token}`);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const environment = env || determineEnv(chainId);
|
|
157
|
-
|
|
158
|
-
const publicClient = makePublicClient({ chainId, rpcUrl, env: environment });
|
|
159
|
-
const tokenContract = await getTokenContractInfo(
|
|
160
|
-
token,
|
|
161
|
-
chainId,
|
|
162
|
-
environment,
|
|
163
|
-
AddressKind.Adapter,
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
let value = 0n;
|
|
167
|
-
if (isUpgradedAbi(tokenContract.abi) || token === Token.BTCb) {
|
|
168
|
-
const assetRouterAddress = await publicClient.readContract({
|
|
169
|
-
abi: tokenContract.abi,
|
|
170
|
-
address: tokenContract.address,
|
|
171
|
-
functionName: 'getAssetRouter',
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
const assetRouter = {
|
|
175
|
-
abi: ASSET_ROUTER_ABI,
|
|
176
|
-
address: assetRouterAddress,
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const [, redeemForBtcMinAmountValue] = (await publicClient.readContract({
|
|
180
|
-
abi: assetRouter.abi,
|
|
181
|
-
address: assetRouter.address,
|
|
182
|
-
functionName: 'tokenConfig',
|
|
183
|
-
args: [tokenContract.address],
|
|
184
|
-
})) as [undefined, bigint];
|
|
185
|
-
|
|
186
|
-
value = redeemForBtcMinAmountValue;
|
|
187
|
-
} else {
|
|
188
|
-
// legacy (and BTCK v1)
|
|
189
|
-
value = 2000n; // 0.00002
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return fromSatoshi(String(value));
|
|
193
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './getLBTCMintingFee';
|