@lombard.finance/sdk 4.0.0 → 4.1.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 +6 -0
- package/dist/common/feature-config.d.ts.map +1 -1
- package/dist/index2.cjs +6 -6
- package/dist/index2.js +762 -754
- 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,121 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import BigNumber from 'bignumber.js';
|
|
3
|
-
import { extractChain, PublicClient } from 'viem';
|
|
4
|
-
import * as chains from 'viem/chains';
|
|
5
|
-
|
|
6
|
-
import { makePublicClient } from '../../../clients/public-client';
|
|
7
|
-
import { getApiConfig } from '../../../common/api-config';
|
|
8
|
-
import { IEnvParam } from '../../../common/parameters';
|
|
9
|
-
import { Token } from '../../../tokens/token-addresses';
|
|
10
|
-
import {
|
|
11
|
-
fromBaseDenomination,
|
|
12
|
-
getTokenContractInfo,
|
|
13
|
-
retrieveTokenProperties,
|
|
14
|
-
} from '../../../tokens/tokens';
|
|
15
|
-
import { Vault, VAULTS, VedaVaultChain } from '../config';
|
|
16
|
-
|
|
17
|
-
export type GetVaultBtcHolding = {
|
|
18
|
-
vaultKey?: Vault;
|
|
19
|
-
rpcUrls?: Record<VedaVaultChain, string>;
|
|
20
|
-
};
|
|
21
|
-
export async function getVaultBtcHolding({
|
|
22
|
-
vaultKey = Vault.Veda,
|
|
23
|
-
rpcUrls,
|
|
24
|
-
}: GetVaultBtcHolding) {
|
|
25
|
-
const vault = VAULTS[vaultKey];
|
|
26
|
-
if (!vault) {
|
|
27
|
-
throw new Error(`Unknown vault key: ${vaultKey}`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const clients: Partial<Record<VedaVaultChain, PublicClient>> = {};
|
|
31
|
-
for (const chainId of vault.chains) {
|
|
32
|
-
const publicClient = makePublicClient({
|
|
33
|
-
chainId: chainId,
|
|
34
|
-
rpcUrl: rpcUrls?.[chainId],
|
|
35
|
-
});
|
|
36
|
-
clients[chainId] = publicClient;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const balances = [];
|
|
40
|
-
|
|
41
|
-
for (const [token, chainIds] of Object.entries(vault.tokens)) {
|
|
42
|
-
for (const chainId of chainIds) {
|
|
43
|
-
const tokenContract = await getTokenContractInfo(token as Token, chainId);
|
|
44
|
-
|
|
45
|
-
const publicClient = clients[chainId];
|
|
46
|
-
if (!publicClient) continue;
|
|
47
|
-
|
|
48
|
-
const tokenInfo = await retrieveTokenProperties(
|
|
49
|
-
publicClient,
|
|
50
|
-
tokenContract,
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
if (!tokenInfo) continue;
|
|
54
|
-
|
|
55
|
-
const balanceRaw = await publicClient.readContract({
|
|
56
|
-
abi: tokenContract.abi,
|
|
57
|
-
address: tokenContract.address,
|
|
58
|
-
functionName: 'balanceOf',
|
|
59
|
-
args: [vault.vaultContract.address],
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const balance = fromBaseDenomination(
|
|
63
|
-
balanceRaw ? String(balanceRaw) : 0,
|
|
64
|
-
tokenInfo.decimals,
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const ch = extractChain({ chains: Object.values(chains), id: chainId });
|
|
68
|
-
console.info(`Balance of ${token} on ${ch.name}: ${balance}`);
|
|
69
|
-
|
|
70
|
-
balances.push(balance);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return BigNumber.sum.apply(null, balances);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export type GetVaultTVLParameters = {
|
|
78
|
-
vaultKey?: Vault;
|
|
79
|
-
} & IEnvParam;
|
|
80
|
-
|
|
81
|
-
type DuneQueryResult = {
|
|
82
|
-
net_btc_balance: number;
|
|
83
|
-
price: number;
|
|
84
|
-
vault_tvl: number;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
type Response = {
|
|
88
|
-
/** The TVL represented in BTC locked in the vault */
|
|
89
|
-
btcBalance: BigNumber;
|
|
90
|
-
/** The BTC price in US dollars */
|
|
91
|
-
btcPrice: BigNumber;
|
|
92
|
-
/** The TVL represented us US dollars */
|
|
93
|
-
tvl: BigNumber;
|
|
94
|
-
};
|
|
95
|
-
export async function getVaultTVL({
|
|
96
|
-
vaultKey = Vault.Veda,
|
|
97
|
-
env,
|
|
98
|
-
}: GetVaultTVLParameters) {
|
|
99
|
-
const vault = VAULTS[vaultKey];
|
|
100
|
-
if (!vault) {
|
|
101
|
-
throw new Error(`Unknown vault key: ${vaultKey}`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const { bffApiUrl } = getApiConfig(env);
|
|
105
|
-
if (!bffApiUrl) {
|
|
106
|
-
throw new Error(
|
|
107
|
-
`Could not determine API endpoint for provided environment: ${env}`,
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const url = `${bffApiUrl}/dune-api/query/vault-tvl`;
|
|
112
|
-
const { data } = await axios.get<DuneQueryResult>(url);
|
|
113
|
-
|
|
114
|
-
const response: Response = {
|
|
115
|
-
btcBalance: BigNumber(data.net_btc_balance),
|
|
116
|
-
btcPrice: BigNumber(data.price),
|
|
117
|
-
tvl: BigNumber(data.vault_tvl),
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
return response;
|
|
121
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { Button } from '../../../stories/components/Button';
|
|
4
|
-
import { CodeBlock } from '../../../stories/components/CodeBlock';
|
|
5
|
-
import { ConnectButton } from '../../../stories/components/ConnectButton';
|
|
6
|
-
import {
|
|
7
|
-
functionType,
|
|
8
|
-
wagmiDecorator,
|
|
9
|
-
} from '../../../stories/components/decorators';
|
|
10
|
-
import { ErrorBlock } from '../../../stories/components/error-block';
|
|
11
|
-
import {
|
|
12
|
-
canPerformAction,
|
|
13
|
-
useConnection,
|
|
14
|
-
} from '../../../stories/hooks/useConnection';
|
|
15
|
-
import useQuery from '../../../stories/hooks/useQuery';
|
|
16
|
-
import { Vault } from '../config';
|
|
17
|
-
import { cancelWithdraw,CancelWithdrawParameters } from './withdraw';
|
|
18
|
-
|
|
19
|
-
const meta = {
|
|
20
|
-
title: 'vault/ops/cancelWithdraw',
|
|
21
|
-
component: StoryView,
|
|
22
|
-
tags: ['autodocs'],
|
|
23
|
-
decorators: [wagmiDecorator, functionType('write')],
|
|
24
|
-
} satisfies Meta<typeof StoryView>;
|
|
25
|
-
|
|
26
|
-
export default meta;
|
|
27
|
-
|
|
28
|
-
type Story = StoryObj<typeof meta>;
|
|
29
|
-
|
|
30
|
-
export const WithParams: Story = {
|
|
31
|
-
args: {
|
|
32
|
-
vaultKey: Vault.Veda,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
type SignNetworkFeeProps = Omit<
|
|
37
|
-
CancelWithdrawParameters,
|
|
38
|
-
'account' | 'chainId' | 'provider'
|
|
39
|
-
>;
|
|
40
|
-
|
|
41
|
-
export function StoryView(props: SignNetworkFeeProps) {
|
|
42
|
-
const connection = useConnection();
|
|
43
|
-
|
|
44
|
-
const request = async () => {
|
|
45
|
-
if (!canPerformAction(connection)) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return cancelWithdraw({
|
|
50
|
-
...props,
|
|
51
|
-
|
|
52
|
-
account: connection.account.address,
|
|
53
|
-
chainId: connection.account.chainId,
|
|
54
|
-
provider: connection.provider,
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const { data, error, isLoading, refetch } = useQuery(request, [], false);
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<>
|
|
62
|
-
<p>This method queues withdraw from the chosen DeFi vault.</p>
|
|
63
|
-
|
|
64
|
-
<div className="mb-4">
|
|
65
|
-
<ConnectButton />
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
<Button
|
|
69
|
-
onClick={refetch}
|
|
70
|
-
disabled={isLoading || !connection.account.address}
|
|
71
|
-
isLoading={isLoading}
|
|
72
|
-
actionName={cancelWithdraw.name}
|
|
73
|
-
/>
|
|
74
|
-
|
|
75
|
-
<ErrorBlock>{error}</ErrorBlock>
|
|
76
|
-
|
|
77
|
-
<CodeBlock text={data} />
|
|
78
|
-
</>
|
|
79
|
-
);
|
|
80
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { Button } from '../../../stories/components/Button';
|
|
4
|
-
import { CodeBlock } from '../../../stories/components/CodeBlock';
|
|
5
|
-
import { ConnectButton } from '../../../stories/components/ConnectButton';
|
|
6
|
-
import {
|
|
7
|
-
functionType,
|
|
8
|
-
wagmiDecorator,
|
|
9
|
-
} from '../../../stories/components/decorators';
|
|
10
|
-
import { ErrorBlock } from '../../../stories/components/error-block';
|
|
11
|
-
import {
|
|
12
|
-
canPerformAction,
|
|
13
|
-
useConnection,
|
|
14
|
-
} from '../../../stories/hooks/useConnection';
|
|
15
|
-
import useQuery from '../../../stories/hooks/useQuery';
|
|
16
|
-
import { Vault } from '../config';
|
|
17
|
-
import { deposit,DepositParameters } from './deposit';
|
|
18
|
-
|
|
19
|
-
const meta = {
|
|
20
|
-
title: 'vault/ops/deposit',
|
|
21
|
-
component: StoryView,
|
|
22
|
-
tags: ['autodocs'],
|
|
23
|
-
decorators: [wagmiDecorator, functionType('write')],
|
|
24
|
-
} satisfies Meta<typeof StoryView>;
|
|
25
|
-
|
|
26
|
-
export default meta;
|
|
27
|
-
|
|
28
|
-
type Story = StoryObj<typeof meta>;
|
|
29
|
-
|
|
30
|
-
export const WithParams: Story = {
|
|
31
|
-
args: {
|
|
32
|
-
vaultKey: Vault.Veda,
|
|
33
|
-
amount: '0.0001',
|
|
34
|
-
approve: true,
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
type SignNetworkFeeProps = Omit<
|
|
39
|
-
DepositParameters,
|
|
40
|
-
'account' | 'chainId' | 'provider'
|
|
41
|
-
>;
|
|
42
|
-
|
|
43
|
-
export function StoryView(props: SignNetworkFeeProps) {
|
|
44
|
-
const connection = useConnection();
|
|
45
|
-
|
|
46
|
-
const request = async () => {
|
|
47
|
-
if (!canPerformAction(connection)) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return deposit({
|
|
52
|
-
...props,
|
|
53
|
-
|
|
54
|
-
account: connection.account.address,
|
|
55
|
-
chainId: connection.account.chainId,
|
|
56
|
-
provider: connection.provider,
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const { data, error, isLoading, refetch } = useQuery(request, [], false);
|
|
61
|
-
|
|
62
|
-
return (
|
|
63
|
-
<>
|
|
64
|
-
<p>This method deposits funds to the chosen DeFi vault.</p>
|
|
65
|
-
|
|
66
|
-
<div className="mb-4">
|
|
67
|
-
<ConnectButton />
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
<Button
|
|
71
|
-
onClick={refetch}
|
|
72
|
-
disabled={isLoading || !connection.account.address}
|
|
73
|
-
isLoading={isLoading}
|
|
74
|
-
actionName={deposit.name}
|
|
75
|
-
/>
|
|
76
|
-
|
|
77
|
-
<ErrorBlock>{error}</ErrorBlock>
|
|
78
|
-
|
|
79
|
-
<CodeBlock text={data} />
|
|
80
|
-
</>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import BigNumber from 'bignumber.js';
|
|
2
|
-
|
|
3
|
-
import { makePublicClient } from '../../../clients/public-client';
|
|
4
|
-
import { makeWalletClient } from '../../../clients/wallet-client';
|
|
5
|
-
import { CHAIN_ID_TO_VIEM_CHAIN_MAP } from '../../../common/chains';
|
|
6
|
-
import { CommonWriteParameters } from '../../../common/parameters';
|
|
7
|
-
import { Token } from '../../../tokens/token-addresses';
|
|
8
|
-
import {
|
|
9
|
-
fromBaseDenomination,
|
|
10
|
-
getTokenInfo,
|
|
11
|
-
toBaseDenomination,
|
|
12
|
-
} from '../../../tokens/tokens';
|
|
13
|
-
import { getErrorMessage } from '../../../utils/err';
|
|
14
|
-
import toBigInt from '../../../utils/numbers';
|
|
15
|
-
import { isVedaVaultChain, Vault, VAULTS } from '../config';
|
|
16
|
-
|
|
17
|
-
export type DepositParameters = {
|
|
18
|
-
/** The amount to be deposited into the DeFi vault. */
|
|
19
|
-
amount: BigNumber.Value;
|
|
20
|
-
/**
|
|
21
|
-
* A flag determining whether the amount should be approved within
|
|
22
|
-
* the execution of this function. If set to `false` it will
|
|
23
|
-
* throw an error when the deposit amount exceeds allowance.
|
|
24
|
-
*/
|
|
25
|
-
approve?: boolean;
|
|
26
|
-
/** The optional deposit asset. */
|
|
27
|
-
token?: Token;
|
|
28
|
-
/** The vault identifier. */
|
|
29
|
-
vaultKey?: Vault;
|
|
30
|
-
} & CommonWriteParameters;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Deposits specified amount to the chosen DeFi vault.
|
|
34
|
-
* @param {DepositParameters} parameters
|
|
35
|
-
* @param {BigNumber.Value} parameters.amount - The deposit amount.
|
|
36
|
-
* @param {boolean} parameters.approve - The optional flag determining whether approve actions should be performed.
|
|
37
|
-
* @param {Token} parameters.token - The optional deposit asset.
|
|
38
|
-
* @param {Vault} parameters.vaultKey - The vault identifier.
|
|
39
|
-
* @param {Address} parameters.account - The EVM account address.
|
|
40
|
-
* @param {ChainId} parameters.chainId - The chain id.
|
|
41
|
-
* @param {EIP1193Provider} parameters.provider - The EIP1193 provider.
|
|
42
|
-
* @param {string} parameters.rpcUrl - The optional rpc url.
|
|
43
|
-
*
|
|
44
|
-
* @returns {Promise<Hash>}
|
|
45
|
-
*/
|
|
46
|
-
export async function deposit({
|
|
47
|
-
amount: amountRaw,
|
|
48
|
-
approve = true,
|
|
49
|
-
token = Token.LBTC,
|
|
50
|
-
vaultKey = Vault.Veda,
|
|
51
|
-
account,
|
|
52
|
-
chainId,
|
|
53
|
-
provider,
|
|
54
|
-
rpcUrl,
|
|
55
|
-
env,
|
|
56
|
-
}: DepositParameters) {
|
|
57
|
-
const vault = VAULTS[vaultKey];
|
|
58
|
-
if (!vault) {
|
|
59
|
-
throw new Error(`Unknown vault key: ${vaultKey}`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!isVedaVaultChain(chainId)) {
|
|
63
|
-
throw new Error(
|
|
64
|
-
`Unsupported chain id: ${chainId}. Please switch to one of the supported chains: ${vault.chains.join(', ')}`,
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const publicClient = makePublicClient({ chainId, rpcUrl });
|
|
69
|
-
const walletClient = makeWalletClient({ provider, chainId });
|
|
70
|
-
|
|
71
|
-
const depositToken = await getTokenInfo(token, chainId, env, rpcUrl);
|
|
72
|
-
if (!depositToken) {
|
|
73
|
-
throw new Error(`Unknown deposit token: ${token}`);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const amount = BigNumber(amountRaw);
|
|
77
|
-
const amountBase = toBigInt(
|
|
78
|
-
toBaseDenomination(amount, depositToken.decimals),
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const allowanceRaw = await publicClient.readContract({
|
|
82
|
-
address: depositToken.address,
|
|
83
|
-
abi: depositToken.abi,
|
|
84
|
-
functionName: 'allowance',
|
|
85
|
-
args: [account, vault.vaultContract.address],
|
|
86
|
-
});
|
|
87
|
-
const allowance = fromBaseDenomination(
|
|
88
|
-
String(allowanceRaw),
|
|
89
|
-
depositToken.decimals,
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const balanceRaw = await publicClient.readContract({
|
|
93
|
-
address: depositToken.address,
|
|
94
|
-
abi: depositToken.abi,
|
|
95
|
-
functionName: 'balanceOf',
|
|
96
|
-
args: [account],
|
|
97
|
-
});
|
|
98
|
-
const balance = fromBaseDenomination(
|
|
99
|
-
String(balanceRaw),
|
|
100
|
-
depositToken.decimals,
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
// check if amount exceeds balance
|
|
104
|
-
if (amount.isGreaterThan(balance)) {
|
|
105
|
-
throw new Error(
|
|
106
|
-
`The deposit amount exceeds the account's balance. \nDeposit amount: ${amount.toFixed()} \nBalance: ${balance.toFixed()}`,
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// check if amount exceeds allowance
|
|
111
|
-
if (amount.isGreaterThan(allowance)) {
|
|
112
|
-
const exceededMessage = `The deposit amount exceeds allowance. \nDeposit amount: ${amount.toFixed()} \nAllowance: ${allowance.toFixed()}`;
|
|
113
|
-
if (!approve) {
|
|
114
|
-
throw new Error(exceededMessage);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// try to approve new amount
|
|
118
|
-
console.info(exceededMessage);
|
|
119
|
-
try {
|
|
120
|
-
console.info(`Trying to approve ${amountBase}`);
|
|
121
|
-
const { request } = await publicClient.simulateContract({
|
|
122
|
-
account,
|
|
123
|
-
chain: CHAIN_ID_TO_VIEM_CHAIN_MAP[chainId],
|
|
124
|
-
address: depositToken.address,
|
|
125
|
-
abi: depositToken.abi,
|
|
126
|
-
functionName: 'approve',
|
|
127
|
-
args: [vault.vaultContract.address, amountBase],
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
const txHash = await walletClient.writeContract(request);
|
|
131
|
-
console.info(`Approve tx hash: ${txHash}`);
|
|
132
|
-
console.info(`Approved ${amountBase} for ${vault.vaultContract.address}`);
|
|
133
|
-
} catch (err) {
|
|
134
|
-
const msg = getErrorMessage(err);
|
|
135
|
-
throw new Error(
|
|
136
|
-
`Could not approve ${amountBase} for ${vault.vaultContract.address}. \nReason: ${msg}`,
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// deposit funds via the teller contract
|
|
142
|
-
const { request } = await publicClient.simulateContract({
|
|
143
|
-
account,
|
|
144
|
-
chain: CHAIN_ID_TO_VIEM_CHAIN_MAP[chainId],
|
|
145
|
-
address: vault.tellerContracts[chainId].address,
|
|
146
|
-
abi: vault.tellerContracts[chainId].abi,
|
|
147
|
-
functionName: 'deposit',
|
|
148
|
-
args: [depositToken.address, amountBase, 0n],
|
|
149
|
-
});
|
|
150
|
-
const txHash = await walletClient.writeContract(request);
|
|
151
|
-
return txHash;
|
|
152
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { ChainId } from '../../../common/chains';
|
|
4
|
-
import { Button } from '../../../stories/components/Button';
|
|
5
|
-
import { CodeBlock } from '../../../stories/components/CodeBlock';
|
|
6
|
-
import {
|
|
7
|
-
functionType,
|
|
8
|
-
wagmiDecorator,
|
|
9
|
-
} from '../../../stories/components/decorators';
|
|
10
|
-
import { ErrorBlock } from '../../../stories/components/error-block';
|
|
11
|
-
import { EXAMPLE_EVM_ADDRESS } from '../../../stories/constants';
|
|
12
|
-
import useQuery from '../../../stories/hooks/useQuery';
|
|
13
|
-
import { Vault } from '../config';
|
|
14
|
-
import {
|
|
15
|
-
getVaultDeposits,
|
|
16
|
-
GetVaultDepositsParameters,
|
|
17
|
-
} from './get-vault-deposits';
|
|
18
|
-
|
|
19
|
-
const meta = {
|
|
20
|
-
title: 'vault/ops/getVaultDeposits',
|
|
21
|
-
component: StoryView,
|
|
22
|
-
tags: ['autodocs'],
|
|
23
|
-
decorators: [wagmiDecorator, functionType('api-get')],
|
|
24
|
-
} satisfies Meta<typeof StoryView>;
|
|
25
|
-
|
|
26
|
-
export default meta;
|
|
27
|
-
|
|
28
|
-
type Story = StoryObj<typeof meta>;
|
|
29
|
-
|
|
30
|
-
export const WithParams: Story = {
|
|
31
|
-
args: {
|
|
32
|
-
account: EXAMPLE_EVM_ADDRESS,
|
|
33
|
-
chainId: ChainId.ethereum,
|
|
34
|
-
vaultKey: Vault.Veda,
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
type SignNetworkFeeProps = GetVaultDepositsParameters;
|
|
39
|
-
|
|
40
|
-
export function StoryView(props: SignNetworkFeeProps) {
|
|
41
|
-
const request = async () => {
|
|
42
|
-
return getVaultDeposits({
|
|
43
|
-
...props,
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const { data, error, isLoading, refetch } = useQuery(request, [], false);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<>
|
|
51
|
-
<p>This function gets the deposits made by a user to the DeFi vault.</p>
|
|
52
|
-
|
|
53
|
-
<Button
|
|
54
|
-
onClick={refetch}
|
|
55
|
-
disabled={isLoading}
|
|
56
|
-
isLoading={isLoading}
|
|
57
|
-
actionName={getVaultDeposits.name}
|
|
58
|
-
/>
|
|
59
|
-
|
|
60
|
-
<ErrorBlock>{error}</ErrorBlock>
|
|
61
|
-
|
|
62
|
-
<CodeBlock text={data} />
|
|
63
|
-
</>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import BigNumber from 'bignumber.js';
|
|
3
|
-
import { Address, Hash } from 'viem';
|
|
4
|
-
|
|
5
|
-
import { getApiConfig } from '../../../common/api-config';
|
|
6
|
-
import { ChainId } from '../../../common/chains';
|
|
7
|
-
import { IEnvParam } from '../../../common/parameters';
|
|
8
|
-
import {
|
|
9
|
-
fromBaseDenomination,
|
|
10
|
-
getAssetInfo,
|
|
11
|
-
TokenInfo,
|
|
12
|
-
} from '../../../tokens/tokens';
|
|
13
|
-
import { orderBy, unique } from '../../../utils/array';
|
|
14
|
-
import { ensureHex } from '../../../utils/hex';
|
|
15
|
-
import {
|
|
16
|
-
isVedaVaultChain,
|
|
17
|
-
NETWORK_TO_VEDA_VAULT_CHAIN_MAP,
|
|
18
|
-
Vault,
|
|
19
|
-
VAULTS,
|
|
20
|
-
VEDA_VAULT_CHAIN_TO_NETWORK_MAP,
|
|
21
|
-
VedaVaultChain,
|
|
22
|
-
} from '../config';
|
|
23
|
-
|
|
24
|
-
type SevenSeasDepositEntry = {
|
|
25
|
-
block_number: number;
|
|
26
|
-
chain: string;
|
|
27
|
-
deposit_amount: number;
|
|
28
|
-
deposit_asset: string;
|
|
29
|
-
share_amount: number;
|
|
30
|
-
tx_hash: string;
|
|
31
|
-
user: string;
|
|
32
|
-
vault_address: string;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
type SevenSeasDepositsPayload =
|
|
36
|
-
| SevenSeasDepositEntry
|
|
37
|
-
| SevenSeasDepositEntry[]
|
|
38
|
-
| { Response: SevenSeasDepositEntry }
|
|
39
|
-
| { Response: SevenSeasDepositEntry[] };
|
|
40
|
-
|
|
41
|
-
const normalizeSevenSeasDeposits = (
|
|
42
|
-
payload: SevenSeasDepositsPayload | undefined,
|
|
43
|
-
): SevenSeasDepositEntry[] => {
|
|
44
|
-
if (!payload) {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (Array.isArray(payload)) {
|
|
49
|
-
return payload;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if ('Response' in payload) {
|
|
53
|
-
const response = payload.Response;
|
|
54
|
-
if (Array.isArray(response)) {
|
|
55
|
-
return response;
|
|
56
|
-
}
|
|
57
|
-
if (response) {
|
|
58
|
-
return [response];
|
|
59
|
-
}
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return [payload];
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export type GetVaultDepositsParameters = IEnvParam & {
|
|
67
|
-
account: Address;
|
|
68
|
-
chainId: ChainId;
|
|
69
|
-
vaultKey?: Vault;
|
|
70
|
-
rpcUrl?: string;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export type VaultDeposit = {
|
|
74
|
-
/** The transaction hash */
|
|
75
|
-
txHash: Hash;
|
|
76
|
-
/** The transaction's block number */
|
|
77
|
-
blockNumber: number;
|
|
78
|
-
/** The chain id */
|
|
79
|
-
chainId: VedaVaultChain;
|
|
80
|
-
/** The deposited amount */
|
|
81
|
-
amount: BigNumber;
|
|
82
|
-
/** The amount of shares received */
|
|
83
|
-
shareAmount: BigNumber;
|
|
84
|
-
/** The deposit token */
|
|
85
|
-
token?: Omit<TokenInfo, 'abi'>;
|
|
86
|
-
/** The user wallet address that made the deposit */
|
|
87
|
-
toAddress: Address;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Retrieves the deposits made by specified address.
|
|
92
|
-
* @param parameters - The parameters.
|
|
93
|
-
* @param parameters.account - The account address.
|
|
94
|
-
* @param parameters.chainId - The chain id.
|
|
95
|
-
* @param parameters.vaultKey - The optional vault identifier.
|
|
96
|
-
* @param parameters.rpcUrl - The optional RPC url.
|
|
97
|
-
*
|
|
98
|
-
* @returns {Promise<VaultDeposit[]>}
|
|
99
|
-
*/
|
|
100
|
-
export async function getVaultDeposits({
|
|
101
|
-
account,
|
|
102
|
-
chainId,
|
|
103
|
-
vaultKey = Vault.Veda,
|
|
104
|
-
rpcUrl,
|
|
105
|
-
env,
|
|
106
|
-
}: GetVaultDepositsParameters) {
|
|
107
|
-
const vault = VAULTS[vaultKey];
|
|
108
|
-
if (!vault) {
|
|
109
|
-
throw new Error(`Unknown vault key: ${vaultKey}`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (!isVedaVaultChain(chainId)) {
|
|
113
|
-
throw new Error(
|
|
114
|
-
`Unsupported chain id: ${chainId}. Please switch to one of the supported chains: ${vault.chains.join(', ')}`,
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const network = VEDA_VAULT_CHAIN_TO_NETWORK_MAP[chainId];
|
|
119
|
-
const { bffApiUrl } = getApiConfig(env);
|
|
120
|
-
if (!bffApiUrl) {
|
|
121
|
-
throw new Error(
|
|
122
|
-
`Could not determine API endpoint for provided environment: ${env}`,
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
const url = `${bffApiUrl}/sevenseas-api/deposits/${network}/${vault.vaultContract.address}/${account}`;
|
|
126
|
-
|
|
127
|
-
const { data } = await axios.get<SevenSeasDepositsPayload>(url);
|
|
128
|
-
const entries = normalizeSevenSeasDeposits(data);
|
|
129
|
-
|
|
130
|
-
const depositAssetsAddresses = unique(
|
|
131
|
-
entries.map(d => ensureHex(d.deposit_asset)),
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
const depositAssets: Record<Address, Omit<TokenInfo, 'abi'> | undefined> = {};
|
|
135
|
-
for (const asset of depositAssetsAddresses) {
|
|
136
|
-
const assetInfo = await getAssetInfo(asset, chainId, rpcUrl);
|
|
137
|
-
if (assetInfo) {
|
|
138
|
-
depositAssets[asset] = {
|
|
139
|
-
address: assetInfo.address,
|
|
140
|
-
decimals: assetInfo.decimals,
|
|
141
|
-
symbol: assetInfo.symbol,
|
|
142
|
-
};
|
|
143
|
-
} else {
|
|
144
|
-
depositAssets[asset] = undefined;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const deposits = entries.map(d => {
|
|
149
|
-
const token = depositAssets[ensureHex(d.deposit_asset)];
|
|
150
|
-
const amount = fromBaseDenomination(d.deposit_amount, token?.decimals || 0);
|
|
151
|
-
const shareAmount = fromBaseDenomination(d.share_amount, vault.decimals);
|
|
152
|
-
|
|
153
|
-
const vaultDeposit: VaultDeposit = {
|
|
154
|
-
txHash: ensureHex(d.tx_hash),
|
|
155
|
-
blockNumber: d.block_number,
|
|
156
|
-
chainId: NETWORK_TO_VEDA_VAULT_CHAIN_MAP[d.chain],
|
|
157
|
-
amount,
|
|
158
|
-
shareAmount,
|
|
159
|
-
token,
|
|
160
|
-
toAddress: ensureHex(d.user),
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
return vaultDeposit;
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
return orderBy(deposits, d => d.blockNumber, 'desc');
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export type GetVaultDepositsAllChainsParameters = {
|
|
170
|
-
account: Address;
|
|
171
|
-
vaultKey?: Vault;
|
|
172
|
-
rpcUrl?: string;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Retrieves the deposits made by specified address across all supported chains for a vault.
|
|
177
|
-
* This is useful for getting a complete view of all deposits regardless of the currently connected chain.
|
|
178
|
-
*
|
|
179
|
-
* @param parameters - The parameters.
|
|
180
|
-
* @param parameters.account - The account address.
|
|
181
|
-
* @param parameters.vaultKey - The optional vault identifier (defaults to Veda).
|
|
182
|
-
* @param parameters.rpcUrl - The optional RPC url.
|
|
183
|
-
*
|
|
184
|
-
* @returns {Promise<VaultDeposit[]>} All deposits across all supported chains, sorted by block number (newest first)
|
|
185
|
-
*/
|
|
186
|
-
export async function getVaultDepositsAllChains({
|
|
187
|
-
account,
|
|
188
|
-
vaultKey = Vault.Veda,
|
|
189
|
-
rpcUrl,
|
|
190
|
-
}: GetVaultDepositsAllChainsParameters): Promise<VaultDeposit[]> {
|
|
191
|
-
const vault = VAULTS[vaultKey];
|
|
192
|
-
if (!vault) {
|
|
193
|
-
throw new Error(`Unknown vault key: ${vaultKey}`);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Fetch deposits from all supported chains in parallel
|
|
197
|
-
const depositsPromises = vault.chains.map(chainId =>
|
|
198
|
-
getVaultDeposits({ account, chainId, vaultKey, rpcUrl }).catch(error => {
|
|
199
|
-
console.error(`Failed to fetch deposits for chain ${chainId}:`, error);
|
|
200
|
-
return []; // Return empty array on error to not break the entire query
|
|
201
|
-
}),
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
const depositsArrays = await Promise.all(depositsPromises);
|
|
205
|
-
|
|
206
|
-
// Flatten and sort all deposits by block number (newest first)
|
|
207
|
-
const allDeposits = depositsArrays.flat();
|
|
208
|
-
return orderBy(allDeposits, d => d.blockNumber, 'desc');
|
|
209
|
-
}
|