@lombard.finance/sdk 0.2.0 → 0.4.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.
@@ -1,4 +1,5 @@
1
1
  export * from './approveLBTC';
2
2
  export * from './claimLBTC';
3
+ export * from './lbtcAddressConfig';
3
4
  export * from './signLbtcDestionationAddr';
4
5
  export * from './unstakeLBTC';
@@ -1,16 +1,27 @@
1
1
  import { defaultEnv } from '../common/const';
2
- import { OChainId, TChainId, TEnv } from '../common/types/types';
2
+ import { OChainId, OEnv, TChainId, TEnv } from '../common/types/types';
3
3
 
4
4
  type LbtcTokenConfig = Partial<Record<TChainId, string>>;
5
5
 
6
- const testnetConfig: LbtcTokenConfig = {
6
+ const stageConfig: LbtcTokenConfig = {
7
7
  [OChainId.holesky]: '0xED7bfd5C1790576105Af4649817f6d35A75CD818',
8
8
  };
9
9
 
10
- const mainnetConfig: LbtcTokenConfig = {
10
+ const testnetConfig: LbtcTokenConfig = {
11
+ [OChainId.holesky]: '0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2',
12
+ };
13
+
14
+ const prodConfig: LbtcTokenConfig = {
11
15
  [OChainId.ethereum]: '0x8236a87084f8b84306f72007f36f2618a5634494',
12
16
  };
13
17
 
14
18
  export function getLbtcAddressConfig(env: TEnv = defaultEnv): LbtcTokenConfig {
15
- return env === 'prod' ? mainnetConfig : testnetConfig;
19
+ switch (env) {
20
+ case OEnv.prod:
21
+ return prodConfig;
22
+ case OEnv.testnet:
23
+ return testnetConfig;
24
+ default:
25
+ return stageConfig;
26
+ }
16
27
  }
@@ -8,7 +8,7 @@ import { getLbtcTokenContract } from '../utils/getLbtcTokenContract';
8
8
 
9
9
  export interface IUnstakeLBTCParams extends IProviderBasedParams, IEnvParam {
10
10
  /**
11
- * The BTC address to send the BTC to.
11
+ * The BTC address to send the unstaked BTC to.
12
12
  */
13
13
  btcAddress: string;
14
14
  /**
@@ -36,7 +36,7 @@ export function unstakeLBTC({
36
36
 
37
37
  const amountSat = toSatoshi(amount);
38
38
 
39
- const tx = tokenContract.methods.burn(outputScript, amountSat);
39
+ const tx = tokenContract.methods.redeem(outputScript, amountSat);
40
40
 
41
41
  return provider.sendTransactionAsync(
42
42
  provider.account,
@@ -1,17 +1,21 @@
1
- import { TChainId, TEnv } from '../../common/types/types';
1
+ import { TEnv } from '../../common/types/types';
2
+ import { isValidChain } from '../../common/utils/isValidChain';
2
3
  import { Provider } from '../../provider';
3
4
  import { getLbtcAddressConfig } from '../lbtcAddressConfig';
4
5
  import { getTokenABI } from './getTokenABI';
5
6
 
6
7
  export function getLbtcTokenContract(provider: Provider, env?: TEnv) {
7
8
  const lbtcAddressConfig = getLbtcAddressConfig(env);
9
+ const { chainId } = provider;
8
10
 
9
- const tokenAddress = lbtcAddressConfig[provider.chainId as TChainId];
11
+ if (!isValidChain(chainId)) {
12
+ throw new Error(`This chain ${chainId} is not supported`);
13
+ }
14
+
15
+ const tokenAddress = lbtcAddressConfig[chainId];
10
16
 
11
17
  if (!tokenAddress) {
12
- throw new Error(
13
- `Token address for chain ${provider.chainId} is not defined`,
14
- );
18
+ throw new Error(`Token address for chain ${chainId} is not defined`);
15
19
  }
16
20
 
17
21
  const abi = getTokenABI('LBTC');