@lombard.finance/sdk 2.2.1 → 2.4.1

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.
Files changed (52) hide show
  1. package/README.md +38 -37
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.js +3017 -728
  5. package/dist/index.js.map +1 -1
  6. package/package.json +6 -6
  7. package/src/common/const.ts +0 -4
  8. package/src/common/types/internalTypes.ts +2 -2
  9. package/src/common/types/types.ts +20 -15
  10. package/src/common/utils/convertSatoshi.ts +11 -7
  11. package/src/index.ts +2 -0
  12. package/src/sdk/apiConfig.ts +9 -5
  13. package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.stories.tsx +1 -1
  14. package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.ts +3 -3
  15. package/src/sdk/getDepositBtcAddress/getDepositBtcAddress.stories.tsx +3 -5
  16. package/src/sdk/getDepositBtcAddress/getDepositBtcAddress.ts +137 -75
  17. package/src/sdk/getDepositBtcAddress/getDepositBtcAddresses.stories.tsx +54 -0
  18. package/src/sdk/getDepositsByAddress/getDepositsByAddress.stories.tsx +1 -1
  19. package/src/sdk/getDepositsByAddress/getDepositsByAddress.ts +5 -4
  20. package/src/sdk/getLBTCExchangeRate/getLBTCExchangeRate.stories.tsx +3 -3
  21. package/src/sdk/getNetworkFeeSignature/getNetworkFeeSignature.stories.tsx +1 -1
  22. package/src/sdk/getPointsByAddress/getPointsByAddress.stories.tsx +49 -0
  23. package/src/sdk/getPointsByAddress/getPointsByAddress.ts +163 -0
  24. package/src/sdk/getPointsByAddress/index.ts +6 -0
  25. package/src/sdk/getUnstakesByAddress/getUnstakesByAddress.stories.tsx +49 -0
  26. package/src/sdk/getUnstakesByAddress/getUnstakesByAddress.ts +133 -0
  27. package/src/sdk/getUnstakesByAddress/index.ts +1 -0
  28. package/src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +1 -1
  29. package/src/sdk/index.ts +3 -1
  30. package/src/sdk/internalTypes.ts +3 -0
  31. package/src/sdk/setReferral/setReferral.ts +6 -5
  32. package/src/sdk/storeNetworkFeeSignature/storeNetworkFeeSignature.stories.tsx +1 -1
  33. package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.stories.tsx +1 -1
  34. package/src/sdk/utils/getChainIdByName.ts +12 -6
  35. package/src/sdk/utils/getChainNameById.ts +25 -15
  36. package/src/web3Sdk/approveLBTC/approveLBTC.stories.tsx +1 -1
  37. package/src/web3Sdk/approveLBTC/approveLBTC.ts +1 -1
  38. package/src/web3Sdk/basculeAddressConfig.ts +7 -8
  39. package/src/web3Sdk/claimLBTC/claimLBTC.stories.tsx +1 -1
  40. package/src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.stories.tsx +5 -2
  41. package/src/web3Sdk/getLBTCTotalSupply/getLBTCTotalSupply.stories.tsx +1 -2
  42. package/src/web3Sdk/lbtcAddressConfig.ts +6 -8
  43. package/src/web3Sdk/signLbtcDestionationAddr/index.ts +1 -1
  44. package/src/web3Sdk/signLbtcDestionationAddr/{signLbtcDestionationAddr.ts → signLbtcDestinationAddr.ts} +4 -4
  45. package/src/web3Sdk/signLbtcDestionationAddr/signLbtcDestionationAddr.stories.tsx +3 -3
  46. package/src/web3Sdk/signNetworkFee/signNetworkFee.stories.tsx +1 -1
  47. package/src/web3Sdk/signStakeAndBake/utils.ts +4 -2
  48. package/src/web3Sdk/unstakeLBTC/unstakeLBTC.stories.tsx +1 -1
  49. package/src/web3Sdk/unstakeLBTC/unstakeLBTC.ts +2 -2
  50. package/src/web3Sdk/utils/chainIdToEnv.ts +4 -3
  51. package/src/web3Sdk/utils/getLbtcTokenContract.ts +5 -2
  52. package/src/btcSdk/utils/getOutputScript.ts +0 -67
@@ -0,0 +1,49 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { defaultEnv } from '@lombard.finance/sdk-common';
3
+ import { Button } from '../../stories/components/Button';
4
+ import { CodeBlock } from '../../stories/components/CodeBlock';
5
+ import { exampleEvmAddress } from '../../stories/const';
6
+ import useQuery from '../../stories/hooks/useQuery';
7
+ import { fromCamelCase } from '../../stories/utils/fromCamelCase';
8
+ import {
9
+ getPointsByAddress,
10
+ IGetPointsByAddressParameters,
11
+ } from './getPointsByAddress';
12
+
13
+ const { name } = getPointsByAddress;
14
+ const nameWithWhitespaces = fromCamelCase(name);
15
+
16
+ const meta = {
17
+ title: 'SDK/getPointsByAddress',
18
+ component: StoryView,
19
+ tags: ['autodocs'],
20
+ } satisfies Meta<typeof StoryView>;
21
+
22
+ export default meta;
23
+
24
+ type Story = StoryObj<typeof meta>;
25
+
26
+ export const WithParams: Story = {
27
+ args: {
28
+ address: exampleEvmAddress,
29
+ env: defaultEnv,
30
+ },
31
+ };
32
+
33
+ export function StoryView(props: IGetPointsByAddressParameters) {
34
+ const { data, error, isLoading, refetch } = useQuery(
35
+ () => getPointsByAddress(props),
36
+ [props],
37
+ false,
38
+ );
39
+
40
+ return (
41
+ <>
42
+ <Button onClick={refetch} disabled={isLoading} isLoading={isLoading}>
43
+ {nameWithWhitespaces}
44
+ </Button>
45
+
46
+ <CodeBlock text={error || data} />
47
+ </>
48
+ );
49
+ }
@@ -0,0 +1,163 @@
1
+ import axios from 'axios';
2
+ import { defaultEnv } from '@lombard.finance/sdk-common';
3
+ import { IEnvParam } from '../../common/types/internalTypes';
4
+ import { getApiConfig } from '../apiConfig';
5
+
6
+ export interface IGetPointsByAddressParameters extends IEnvParam {
7
+ /**
8
+ * The address of the points earner.
9
+ */
10
+ address: string;
11
+ }
12
+
13
+ export interface IProtocolPointsBreakdown {
14
+ [protocolIdentifier: string]: number;
15
+ }
16
+
17
+ export interface IPointsByAddress {
18
+ /**
19
+ * The number of points earned by holding LBTC.
20
+ */
21
+ holdingPoints: number;
22
+ /**
23
+ * The number of points earned by taking positions in DeFi vaults.
24
+ */
25
+ protocolPoints: number;
26
+ /**
27
+ * The number of points earned by your referrals.
28
+ */
29
+ referralPoints: number;
30
+ /**
31
+ * The number of points earned in the OKX campaign.
32
+ */
33
+ okxPoints: number;
34
+ /**
35
+ * The number of points earned by participating in the flash events.
36
+ */
37
+ flashEventPoints: number;
38
+ /**
39
+ * The total number of points.
40
+ */
41
+ totalPoints: number;
42
+ /**
43
+ * The breakdown of points earned from each protocol.
44
+ */
45
+ protocolPointsBreakdown: IProtocolPointsBreakdown;
46
+ }
47
+
48
+ interface IPointsResponse {
49
+ holding_points?: number;
50
+ protocol_points?: number;
51
+ referee_points?: number;
52
+ referrals_points?: number;
53
+ total?: number;
54
+ protocol_points_map?: IProtocolPointsBreakdown;
55
+ }
56
+
57
+ interface IOkxPointsResponse {
58
+ data: boolean;
59
+ points?: string | number;
60
+ }
61
+
62
+ interface IFlashEventPointsResponse {
63
+ flashEvent1Points?: {
64
+ result?: {
65
+ rows?: { points?: string }[]; // take first entry
66
+ };
67
+ };
68
+ flashEvent2Points?: {
69
+ result?: {
70
+ rows?: { totalPoints?: string }[]; // take first entry
71
+ };
72
+ };
73
+ }
74
+
75
+ /**
76
+ * Retrieves the points earned by the provided address.
77
+ * @param {IGetPointsByAddressParameters} parameters
78
+ * @throws {Error} - Throws an error when the API endpoints cannot be determined or any of the API calls fail.
79
+ */
80
+ export async function getPointsByAddress({
81
+ address,
82
+ env,
83
+ }: IGetPointsByAddressParameters): Promise<IPointsByAddress> {
84
+ const { baseApiUrl, bffApiUrl } = getApiConfig(env);
85
+ if (!bffApiUrl || !baseApiUrl) {
86
+ throw new Error(
87
+ `Could not determine the API endpoint for the provided environment: ${env || defaultEnv}`,
88
+ );
89
+ }
90
+
91
+ const lombardPointsUrl = `${baseApiUrl}/api/v1/referral-system/season-1/points/${address}`;
92
+
93
+ /**
94
+ * TODO:
95
+ * OKX and flash event points will be a part of the above endpoint soon.
96
+ * Change this once it is implemented on the backend.
97
+ */
98
+
99
+ const okxPointsUrl = `${baseApiUrl}/api/v1/task/okx/user-task-verification?address=${address}&chain=1`;
100
+ const flashEventsPointsUrl = `${bffApiUrl}/sentio-api/flash-event-points/${address}`;
101
+
102
+ const lombardPointsRequest = axios.get<IPointsResponse>(lombardPointsUrl);
103
+ const okxPointsRequest = axios.get<IOkxPointsResponse>(okxPointsUrl);
104
+ const flashEventPointsRequest =
105
+ axios.get<IFlashEventPointsResponse>(flashEventsPointsUrl);
106
+
107
+ const [
108
+ { data: lombardPointsData },
109
+ { data: okxPointsData },
110
+ { data: flashEventPointsData },
111
+ ] = await Promise.all([
112
+ lombardPointsRequest,
113
+ okxPointsRequest,
114
+ flashEventPointsRequest,
115
+ ]);
116
+
117
+ const okxPoints = parse(okxPointsData?.points);
118
+
119
+ const flashEvent1Points = parse(
120
+ flashEventPointsData?.flashEvent1Points?.result?.rows?.[0]?.points,
121
+ );
122
+ const flashEvent2Points = parse(
123
+ flashEventPointsData?.flashEvent2Points?.result?.rows?.[0]?.totalPoints,
124
+ );
125
+ const flashEventPoints = flashEvent1Points + flashEvent2Points;
126
+
127
+ const holdingPoints = parse(lombardPointsData.holding_points);
128
+ const protocolPoints = parse(lombardPointsData.protocol_points);
129
+ const referralPoints =
130
+ parse(lombardPointsData.referee_points) +
131
+ parse(lombardPointsData.referrals_points);
132
+
133
+ const totalPoints =
134
+ holdingPoints +
135
+ protocolPoints +
136
+ referralPoints +
137
+ okxPoints +
138
+ flashEventPoints;
139
+
140
+ const protocolPointsBreakdown = Object.entries(
141
+ lombardPointsData.protocol_points_map || {},
142
+ ).reduce((acc, [k, v]) => {
143
+ acc[k] = parse(v);
144
+ return acc;
145
+ }, {} as IProtocolPointsBreakdown);
146
+
147
+ return {
148
+ holdingPoints,
149
+ protocolPoints,
150
+ referralPoints,
151
+ okxPoints,
152
+ flashEventPoints,
153
+ totalPoints,
154
+ protocolPointsBreakdown,
155
+ };
156
+ }
157
+
158
+ function parse(
159
+ input: string | number | null | undefined,
160
+ defaultValue = 0,
161
+ ): number {
162
+ return Number(input) || defaultValue;
163
+ }
@@ -0,0 +1,6 @@
1
+ export {
2
+ getPointsByAddress,
3
+ type IGetPointsByAddressParameters,
4
+ type IPointsByAddress,
5
+ type IProtocolPointsBreakdown,
6
+ } from './getPointsByAddress';
@@ -0,0 +1,49 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { defaultEnv } from '@lombard.finance/sdk-common';
3
+ import { Button } from '../../stories/components/Button';
4
+ import { CodeBlock } from '../../stories/components/CodeBlock';
5
+ import { exampleEvmAddress } from '../../stories/const';
6
+ import useQuery from '../../stories/hooks/useQuery';
7
+ import { fromCamelCase } from '../../stories/utils/fromCamelCase';
8
+ import {
9
+ getUnstakesByAddress,
10
+ IGetUnstakesByAddressParameters,
11
+ } from './getUnstakesByAddress';
12
+
13
+ const { name } = getUnstakesByAddress;
14
+ const nameWithWhitespaces = fromCamelCase(name);
15
+
16
+ const meta = {
17
+ title: 'SDK/getUnstakesByAddress',
18
+ component: StoryView,
19
+ tags: ['autodocs'],
20
+ } satisfies Meta<typeof StoryView>;
21
+
22
+ export default meta;
23
+
24
+ type Story = StoryObj<typeof meta>;
25
+
26
+ export const WithParams: Story = {
27
+ args: {
28
+ address: exampleEvmAddress,
29
+ env: defaultEnv,
30
+ },
31
+ };
32
+
33
+ export function StoryView(parameters: IGetUnstakesByAddressParameters) {
34
+ const { data, error, isLoading, refetch } = useQuery(
35
+ () => getUnstakesByAddress(parameters),
36
+ [parameters],
37
+ false,
38
+ );
39
+
40
+ return (
41
+ <>
42
+ <Button onClick={refetch} disabled={isLoading} isLoading={isLoading}>
43
+ {nameWithWhitespaces}
44
+ </Button>
45
+
46
+ <CodeBlock text={error || data} />
47
+ </>
48
+ );
49
+ }
@@ -0,0 +1,133 @@
1
+ import axios from 'axios';
2
+ import { address, networks } from 'bitcoinjs-lib';
3
+
4
+ import { IEnvParam } from '../../common/types/internalTypes';
5
+ import { SuiChain, TChainId } from '../../common/types/types';
6
+ import { fromSatoshi } from '../../common/utils/convertSatoshi';
7
+ import { getApiConfig } from '../../sdk/apiConfig';
8
+ import { TChainName } from '../../sdk/internalTypes';
9
+ import { getChainIdByName } from '../../sdk/utils/getChainIdByName';
10
+ import BigNumber from 'bignumber.js';
11
+
12
+ interface IUnstakeResponse {
13
+ tx_hash: string;
14
+ blockchain: TChainName;
15
+ block_height: string;
16
+ block_time: string;
17
+ from_address: string;
18
+ output_script: string;
19
+ amount: string;
20
+ payout_txid?: string;
21
+ payout_index?: string;
22
+ sanctioned?: boolean;
23
+ }
24
+
25
+ interface IGetUnstakesResponse {
26
+ unstakes?: IUnstakeResponse[];
27
+ }
28
+
29
+ export interface IUnstake {
30
+ /**
31
+ * The unstake transaction hash.
32
+ */
33
+ txHash: string;
34
+ /**
35
+ * The chain id where unstake transaction happened.
36
+ */
37
+ chainId: TChainId | SuiChain;
38
+ /**
39
+ * The block height.
40
+ */
41
+ blockHeight: number;
42
+ /**
43
+ * The timestamp of the unstake transaction.
44
+ */
45
+ unstakeDate: Date;
46
+ /**
47
+ * The initiator of the unstake transaction.
48
+ */
49
+ fromAddress: string;
50
+ /**
51
+ * The destination address to which the funds (BTC) will be transferred.
52
+ */
53
+ toAddress: string;
54
+ /**
55
+ * The amount of BTC unstaked.
56
+ */
57
+ amount: BigNumber;
58
+ /**
59
+ * The BTC payout transaction hash.
60
+ *
61
+ * If empty then the unstake is still pending. The payout tx hash is only
62
+ * present for the completed unstake transactions.
63
+ *
64
+ * A withdrawal period of 9 days is required by Lombard — daily rebalancing
65
+ * cycle — and Babylon — 7 days unbonding period. After that the payout
66
+ * should be completed.
67
+ */
68
+ payoutTxHash?: string;
69
+ /**
70
+ * The index of the payout transaction corresponding to the unstake.
71
+ */
72
+ payoutTxIndex?: number;
73
+ /**
74
+ * A flag indicating whether the unstake transaction has been sanctioned and
75
+ * flagged as suspicious.
76
+ * See: https://docs.lombard.finance/technical-documentation/sanctions-and-risk-monitoring
77
+ */
78
+ sanctioned?: boolean;
79
+ }
80
+
81
+ export interface IGetUnstakesByAddressParameters extends IEnvParam {
82
+ /**
83
+ * The address of an initiator of the unstake.
84
+ */
85
+ address: string;
86
+ }
87
+
88
+ /**
89
+ * Gets all unstakes initiated by the specified address.
90
+ *
91
+ * @throws {Error} - Throws an error when there's no address specified.
92
+ */
93
+ export async function getUnstakesByAddress({
94
+ address,
95
+ env = 'prod',
96
+ }: IGetUnstakesByAddressParameters): Promise<IUnstake[]> {
97
+ const { baseApiUrl } = getApiConfig(env);
98
+
99
+ if (!address) {
100
+ throw new Error('No address specified.');
101
+ }
102
+
103
+ const {
104
+ data: { unstakes = [] },
105
+ } = await axios.get<IGetUnstakesResponse>(
106
+ `/api/v1/address/unstakes/${address}`,
107
+ {
108
+ baseURL: baseApiUrl,
109
+ },
110
+ );
111
+
112
+ return unstakes.map(unstakeData => mapResponse(unstakeData, env));
113
+ }
114
+
115
+ function mapResponse(data: IUnstakeResponse, env: IEnvParam['env']): IUnstake {
116
+ const btcAddress = address.fromOutputScript(
117
+ Buffer.from(data.output_script, 'hex'),
118
+ env === 'prod' ? networks.bitcoin : networks.testnet,
119
+ );
120
+
121
+ return {
122
+ txHash: data.tx_hash,
123
+ chainId: getChainIdByName(data.blockchain, env),
124
+ blockHeight: +data.block_height,
125
+ unstakeDate: new Date(+data.block_time * 1000),
126
+ fromAddress: data.from_address,
127
+ toAddress: btcAddress,
128
+ amount: fromSatoshi(data.amount),
129
+ payoutTxHash: data.payout_txid,
130
+ payoutTxIndex: data.payout_index ? +data.payout_index : undefined,
131
+ sanctioned: data.sanctioned,
132
+ };
133
+ }
@@ -0,0 +1 @@
1
+ export { getUnstakesByAddress } from './getUnstakesByAddress';
@@ -1,4 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
+ import { defaultEnv } from '@lombard.finance/sdk-common';
2
3
  import { Button } from '../../stories/components/Button';
3
4
  import { CodeBlock } from '../../stories/components/CodeBlock';
4
5
  import { useConnect } from '../../stories/hooks/useConnect';
@@ -7,7 +8,6 @@ import {
7
8
  IGetUserStakeAndBakeSignatureParams,
8
9
  getUserStakeAndBakeSignature,
9
10
  } from './getUserStakeAndBakeSignature';
10
- import { defaultEnv } from '../../common/const';
11
11
 
12
12
  const meta = {
13
13
  title: 'SDK/getUserStakeAndBakeSignature',
package/src/sdk/index.ts CHANGED
@@ -4,9 +4,11 @@ export * from './getDepositBtcAddress';
4
4
  export * from './getDepositsByAddress';
5
5
  export * from './getLBTCExchangeRate';
6
6
  export * from './getNetworkFeeSignature';
7
+ export * from './getPointsByAddress';
8
+ export * from './getUnstakesByAddress';
7
9
  export * from './getUserStakeAndBakeSignature';
10
+ export * from './setReferral';
8
11
  export * from './storeNetworkFeeSignature';
9
12
  export * from './storeStakeAndBakeSignature';
10
13
  export * from './utils/getChainIdByName';
11
14
  export * from './utils/getChainNameById';
12
- export * from './setReferral';
@@ -7,6 +7,9 @@ export const OChainName = {
7
7
 
8
8
  bsc: 'DESTINATION_BLOCKCHAIN_BSC',
9
9
  bscOld: 'BLOCKCHAIN_BSC',
10
+
11
+ sui: 'DESTINATION_BLOCKCHAIN_SUI',
12
+ suiOld: 'BLOCKCHAIN_SUI',
10
13
  } as const;
11
14
 
12
15
  export type TChainName = (typeof OChainName)[keyof typeof OChainName];
@@ -13,17 +13,18 @@ export interface ISetReferralParams extends IEnvParam {
13
13
  */
14
14
  address: string;
15
15
  /**
16
- * The signature of the address. The signature is generated by signing the address using EVM wallet.
16
+ * The signature of the address. The signature is generated by signing the address using wallet.
17
+ * Use `signTermsOfService` or `signLbtcDestinationAddr` functions.
17
18
  */
18
19
  signature: string;
19
- /**
20
- * The typed data object used to generate the signature if using a network fee authorization signature.
21
- */
22
- eip712Data: string;
23
20
  /**
24
21
  * The captcha token.
25
22
  */
26
23
  referrerCode: string;
24
+ /**
25
+ * The typed data object used to generate the signature if using a network fee authorization signature.
26
+ */
27
+ eip712Data?: string;
27
28
  }
28
29
 
29
30
  /**
@@ -1,4 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
+ import { defaultEnv } from '@lombard.finance/sdk-common';
2
3
  import { Button } from '../../stories/components/Button';
3
4
  import { CodeBlock } from '../../stories/components/CodeBlock';
4
5
  import { useConnect } from '../../stories/hooks/useConnect';
@@ -7,7 +8,6 @@ import {
7
8
  IStoreNetworkFeeSignatureParams,
8
9
  storeNetworkFeeSignature,
9
10
  } from './storeNetworkFeeSignature';
10
- import { defaultEnv } from '../../common/const';
11
11
 
12
12
  const meta = {
13
13
  title: 'SDK/storeNetworkFeeSignature',
@@ -1,4 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
+ import { defaultEnv } from '@lombard.finance/sdk-common';
2
3
  import { Button } from '../../stories/components/Button';
3
4
  import { CodeBlock } from '../../stories/components/CodeBlock';
4
5
  import { useConnect } from '../../stories/hooks/useConnect';
@@ -9,7 +10,6 @@ import {
9
10
  signStakeAndBake,
10
11
  } from '../../web3Sdk/signStakeAndBake/signStakeAndBake';
11
12
  import { storeStakeAndBakeSignature } from './storeStakeAndBakeSignature';
12
- import { defaultEnv } from '../../common/const';
13
13
 
14
14
  const meta = {
15
15
  title: 'SDK/storeStakeAndBakeSignature',
@@ -1,23 +1,25 @@
1
- import { defaultEnv } from '../../common/const';
1
+ import { defaultEnv } from '@lombard.finance/sdk-common';
2
2
  import {
3
3
  getBaseNetworkByEnv,
4
4
  getBscNetworkByEnv,
5
5
  getEthNetworkByEnv,
6
+ getSuiNetworkByEnv,
6
7
  OChainId,
8
+ SuiChain,
7
9
  TChainId,
8
- TEnv,
9
10
  } from '../../common/types/types';
11
+ import { Env } from '@lombard.finance/sdk-common';
10
12
  import { OChainName, TChainName } from '../internalTypes';
11
13
 
12
14
  /**
13
- * @param chainId the chain ID
14
- *
15
+ * @param chain the chain ID
16
+ * @param env
15
17
  * @returns the chain name
16
18
  */
17
19
  export function getChainIdByName(
18
20
  chain: string,
19
- env: TEnv = defaultEnv,
20
- ): TChainId {
21
+ env: Env = defaultEnv,
22
+ ): TChainId | SuiChain {
21
23
  switch (chain as TChainName) {
22
24
  case OChainName.eth:
23
25
  case OChainName.ethOld:
@@ -31,6 +33,10 @@ export function getChainIdByName(
31
33
  case OChainName.bscOld:
32
34
  return getBscNetworkByEnv(env);
33
35
 
36
+ case OChainName.sui:
37
+ case OChainName.suiOld:
38
+ return getSuiNetworkByEnv(env);
39
+
34
40
  default:
35
41
  return OChainId.ethereum;
36
42
  }
@@ -1,4 +1,4 @@
1
- import { OChainId, TChainId } from '../../common/types/types';
1
+ import { OChainId, SuiChain, TChainId } from '../../common/types/types';
2
2
  import { OChainName, TChainName } from '../internalTypes';
3
3
 
4
4
  /**
@@ -6,19 +6,29 @@ import { OChainName, TChainName } from '../internalTypes';
6
6
  *
7
7
  * @returns the chain name
8
8
  */
9
- export function getChainNameById(chainId: TChainId): TChainName {
10
- switch (chainId) {
11
- case OChainId.ethereum:
12
- case OChainId.holesky:
13
- case OChainId.sepolia:
14
- return OChainName.eth;
15
- case OChainId.base:
16
- case OChainId.baseSepoliaTestnet:
17
- return OChainName.base;
18
- case OChainId.binanceSmartChain:
19
- case OChainId.binanceSmartChainTestnet:
20
- return OChainName.bsc;
21
- default:
22
- throw new Error(`Unknown chain ID: ${chainId}`);
9
+ export function getChainNameById(chainId: TChainId | SuiChain): TChainName {
10
+ if (
11
+ chainId === OChainId.ethereum ||
12
+ chainId === OChainId.holesky ||
13
+ chainId === OChainId.sepolia
14
+ ) {
15
+ return OChainName.eth;
23
16
  }
17
+
18
+ if (chainId === OChainId.base || chainId === OChainId.baseSepoliaTestnet) {
19
+ return OChainName.base;
20
+ }
21
+
22
+ if (
23
+ chainId === OChainId.binanceSmartChain ||
24
+ chainId === OChainId.binanceSmartChainTestnet
25
+ ) {
26
+ return OChainName.bsc;
27
+ }
28
+
29
+ if (chainId === 'sui:testnet' || chainId === 'sui:mainnet') {
30
+ return OChainName.sui;
31
+ }
32
+
33
+ throw new Error(`Unknown chain ID: ${chainId}`);
24
34
  }
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { defaultEnv } from '../../common/const';
2
+ import { defaultEnv } from '@lombard.finance/sdk-common';
3
3
  import { Button } from '../../stories/components/Button';
4
4
  import { CodeBlock } from '../../stories/components/CodeBlock';
5
5
  import { useConnect } from '../../stories/hooks/useConnect';
@@ -31,7 +31,7 @@ export function approveLBTC({
31
31
  }: IApproveLBTCParams): Promise<IWeb3SendResult> {
32
32
  const provider = new Provider(providerParams);
33
33
  const tokenContract = getLbtcTokenContract(provider, env);
34
- const amountSat = toSatoshi(amount);
34
+ const amountSat = toSatoshi(amount).toNumber();
35
35
 
36
36
  const tx = tokenContract.methods.approve(spender, amountSat);
37
37
 
@@ -1,8 +1,7 @@
1
- import {
2
- defaultEnv,
3
- ZERO_ADDRESS as PLACEHOLDER_ADDRESS,
4
- } from '../common/const';
5
- import { OChainId, OEnv, TChainId, TEnv } from '../common/types/types';
1
+ import { ZERO_ADDRESS as PLACEHOLDER_ADDRESS } from '../common/const';
2
+ import { OChainId, TChainId } from '../common/types/types';
3
+
4
+ import { Env, defaultEnv } from '@lombard.finance/sdk-common';
6
5
 
7
6
  type BasculeTokenConfig = Record<TChainId, string>;
8
7
 
@@ -76,12 +75,12 @@ const prodConfig: BasculeTokenConfig = {
76
75
  };
77
76
 
78
77
  export function getBasculeAddressConfig(
79
- env: TEnv = defaultEnv,
78
+ env: Env = defaultEnv,
80
79
  ): BasculeTokenConfig {
81
80
  switch (env) {
82
- case OEnv.prod:
81
+ case Env.prod:
83
82
  return prodConfig;
84
- case OEnv.testnet:
83
+ case Env.testnet:
85
84
  return testnetConfig;
86
85
  default:
87
86
  return stageConfig;
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { defaultEnv } from '../../common/const';
2
+ import { defaultEnv } from '@lombard.finance/sdk-common';
3
3
  import { Button } from '../../stories/components/Button';
4
4
  import { CodeBlock } from '../../stories/components/CodeBlock';
5
5
  import { useConnect } from '../../stories/hooks/useConnect';
@@ -1,10 +1,13 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { defaultEnv } from '../../common/const';
2
+ import { defaultEnv } from '@lombard.finance/sdk-common';
3
3
  import { Button } from '../../stories/components/Button';
4
4
  import { CodeBlock } from '../../stories/components/CodeBlock';
5
5
  import { useConnect } from '../../stories/hooks/useConnect';
6
6
  import useQuery from '../../stories/hooks/useQuery';
7
- import { getBasculeDepositStatus, ICheckBasculeDepositStatusParams } from './getBasculeDepositStatus';
7
+ import {
8
+ getBasculeDepositStatus,
9
+ ICheckBasculeDepositStatusParams,
10
+ } from './getBasculeDepositStatus';
8
11
 
9
12
  const meta = {
10
13
  title: 'Web3SDK/getBasculeDepositStatus',
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { defaultEnv } from '../../common/const';
2
+ import { defaultEnv } from '@lombard.finance/sdk-common';
3
3
  import { Button } from '../../stories/components/Button';
4
4
  import { CodeBlock } from '../../stories/components/CodeBlock';
5
5
  import { useConnect } from '../../stories/hooks/useConnect';
@@ -28,7 +28,6 @@ export const WithParams: Story = {
28
28
  type TotalSupplyLBTCProps = Pick<ILBTCTotalSupplyParams, 'env'>;
29
29
 
30
30
  export function StoryView(props: TotalSupplyLBTCProps) {
31
-
32
31
  const { data: connectData, error: connectError } = useConnect();
33
32
 
34
33
  const request = async () => {