@lombard.finance/sdk 3.6.6 → 3.6.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lombard.finance/sdk",
3
- "version": "3.6.6",
3
+ "version": "3.6.8",
4
4
  "dependencies": {
5
5
  "@lombard.finance/sdk-common": "^3.0.0",
6
6
  "viem": "^2.23.15",
@@ -39,7 +39,10 @@
39
39
  "./clients/*": "./src/clients/*.ts",
40
40
  "./utils/*": "./src/utils/*.ts"
41
41
  },
42
- "files": ["dist", "src"],
42
+ "files": [
43
+ "dist",
44
+ "src"
45
+ ],
43
46
  "license": "MIT",
44
47
  "peerDependencies": {
45
48
  "@layerzerolabs/lz-v2-utilities": "3.0.17",
@@ -59,4 +62,4 @@
59
62
  },
60
63
  "type": "module",
61
64
  "types": "./src/index.ts"
62
- }
65
+ }
@@ -143,7 +143,7 @@ export async function getUnstakesByAddress({
143
143
 
144
144
  function mapResponse(data: IUnstakeResponse, env: IEnvParam['env']): IUnstake {
145
145
  const btcAddress = address.fromOutputScript(
146
- Buffer.from(data.output_script, 'hex'),
146
+ Buffer.from(data.output_script.replace(/^0x/, ''), 'hex'),
147
147
  env === 'prod' ? networks.bitcoin : networks.testnet,
148
148
  );
149
149
 
@@ -8,12 +8,23 @@ import {
8
8
  IGetBasculeDepositStatusParameters,
9
9
  getBasculeDepositStatus,
10
10
  } from './getBasculeDepositStatus';
11
+ import {
12
+ chainSelector,
13
+ envSelector,
14
+ makeTokenSelector,
15
+ } from '../../stories/arg-types';
16
+ import { Token } from '../../tokens/token-addresses';
11
17
 
12
18
  const meta = {
13
19
  title: 'read/getBasculeDepositStatus',
14
20
  component: StoryView,
15
21
  tags: ['autodocs'],
16
22
  decorators: [functionType('read')],
23
+ argTypes: {
24
+ ...chainSelector,
25
+ ...envSelector,
26
+ ...makeTokenSelector([Token.LBTC, Token.NativeLBTC, Token.BTCK]),
27
+ },
17
28
  } satisfies Meta<typeof StoryView>;
18
29
 
19
30
  export default meta;
@@ -10,7 +10,6 @@ import {
10
10
  import { IDeposit } from '../../api-functions/getDepositsByAddress/getDepositsByAddress';
11
11
  import { makePublicClient } from '../../clients/public-client';
12
12
  import { makeWalletClient } from '../../clients/wallet-client';
13
- import { ChainId } from '../../common/chains';
14
13
  import { CommonOptionalWriteParameters } from '../../common/parameters';
15
14
  import LBTC_BASCULE_ABI from '../../tokens/abi/LBTC_BASCULE_ABI.json';
16
15
  import { Token } from '../../tokens/token-addresses';
@@ -81,14 +80,6 @@ export async function getBasculeDepositStatus({
81
80
  );
82
81
  }
83
82
 
84
- // Skip Bascule validation for Katana networks
85
- if (
86
- token === Token.LBTC &&
87
- (chainId === ChainId.katana || chainId === ChainId.katanaTatara)
88
- ) {
89
- return BasculeDepositStatus.REPORTED;
90
- }
91
-
92
83
  const publicClient = makePublicClient({ chainId, rpcUrl, env });
93
84
  const tokenContractInfo = await getTokenContractInfo(token, chainId, env);
94
85
 
@@ -46,8 +46,6 @@ export async function getMintingFee({
46
46
 
47
47
  let rawFeeValue = 0n;
48
48
 
49
- console.log('mint fee', tokenContract);
50
-
51
49
  if (isUpgradedAbi(tokenContractAbi) || token === Token.NativeLBTC) {
52
50
  const assetRouterAddress = await publicClient.readContract({
53
51
  abi: tokenContractAbi,
@@ -134,3 +132,47 @@ export async function getRedeemFee({
134
132
 
135
133
  return fromSatoshi(String(rawFeeValue));
136
134
  }
135
+
136
+ export async function getMinRedeemAmount({
137
+ token,
138
+ chainId,
139
+ rpcUrl,
140
+ env,
141
+ }: { token: Token } & CommonParameters) {
142
+ if (![Token.LBTC, Token.BTCK, Token.NativeLBTC].includes(token)) {
143
+ throw new Error(`Unsupported token: ${token}`);
144
+ }
145
+
146
+ const environment = env || determineEnv(chainId);
147
+
148
+ const publicClient = makePublicClient({ chainId, rpcUrl, env: environment });
149
+ const tokenContract = await getTokenContractInfo(token, chainId, environment);
150
+
151
+ let value = 0n;
152
+ if (isUpgradedAbi(tokenContract.abi) || token === Token.NativeLBTC) {
153
+ const assetRouterAddress = await publicClient.readContract({
154
+ abi: tokenContract.abi,
155
+ address: tokenContract.address,
156
+ functionName: 'getAssetRouter',
157
+ });
158
+
159
+ const assetRouter = {
160
+ abi: ASSET_ROUTER_ABI,
161
+ address: assetRouterAddress,
162
+ };
163
+
164
+ const [, redeemForBtcMinAmountValue] = await publicClient.readContract({
165
+ abi: assetRouter.abi,
166
+ address: assetRouter.address,
167
+ functionName: 'tokenConfig',
168
+ args: [tokenContract.address],
169
+ });
170
+
171
+ value = redeemForBtcMinAmountValue;
172
+ } else {
173
+ // legacy (and BTCK v1)
174
+ value = 2000n; // 0.00002
175
+ }
176
+
177
+ return fromSatoshi(String(value));
178
+ }