@lombard.finance/sdk 2.1.2 → 2.1.3

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.
@@ -0,0 +1,48 @@
1
+ import { TChainId } from '../../common/types/types';
2
+ import { ReadProvider } from '../../provider/ReadProvider';
3
+ import { getRpcUrlConfigFromChain } from '../utils/getRpcUrlConfigFromChain';
4
+ import { STAKE_AND_BAKE } from '../abi';
5
+ import { getErrorMessage } from '../../common/utils/getErrorMessage';
6
+
7
+ export interface IGetStakeAndBakeFeeParams {
8
+ /**
9
+ * Chain ID
10
+ */
11
+ chainId: TChainId;
12
+ /**
13
+ * RPC URL
14
+ */
15
+ rpcUrl?: string;
16
+ /**
17
+ * Vault Address
18
+ */
19
+ vaultAddress: string;
20
+ }
21
+
22
+ /**
23
+ * Get Stake and bake fee.
24
+ *
25
+ * @param chainId - Chain ID
26
+ * @param rpcUrl - RPC URL (optional)
27
+ * @param vaultAddress - Vault Address
28
+ *
29
+ * @returns Stake and bake fee in satoshis
30
+ */
31
+ export async function getStakeAndBakeFee({
32
+ chainId,
33
+ rpcUrl,
34
+ vaultAddress,
35
+ }: IGetStakeAndBakeFeeParams): Promise<string> {
36
+ const rpcUrlConfig = getRpcUrlConfigFromChain(chainId, rpcUrl);
37
+ const provider = new ReadProvider({ chainId, rpcUrlConfig });
38
+
39
+ try {
40
+ const contract = provider.createContract(STAKE_AND_BAKE, vaultAddress);
41
+
42
+ const fee: bigint = await contract.methods.getStakeAndBakeFee().call();
43
+ return fee.toString();
44
+ } catch (error) {
45
+ const errorMessage = getErrorMessage(error);
46
+ throw new Error(errorMessage);
47
+ }
48
+ }
@@ -0,0 +1 @@
1
+ export * from './getStakeAndBakeFee';
@@ -12,3 +12,4 @@ export * from './types';
12
12
  export * from './unstakeLBTC';
13
13
  export * from './getBasculeDepositStatus';
14
14
  export * from './getLBTCTotalSupply';
15
+ export * from './getStakeAndBakeFee';