@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.
- package/README.md +31 -2
- package/dist/index.js +664 -436
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/common/const.ts +1 -1
- package/src/common/types/internalTypes.ts +3 -1
- package/src/common/types/types.ts +1 -0
- package/src/provider/ReadProvider.ts +6 -0
- package/src/sdk/apiConfig.ts +15 -6
- package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.ts +27 -9
- package/src/sdk/getDepositBtcAddress/getDepositBtcAddress.ts +23 -10
- package/src/sdk/getDepositsByAddress/getDepositsByAddress.ts +4 -2
- package/src/sdk/getLBTCExchageRate/getLBTCExchageRate.stories.tsx +46 -0
- package/src/sdk/getLBTCExchageRate/getLBTCExchageRate.ts +43 -0
- package/src/sdk/getLBTCExchageRate/index.ts +1 -0
- package/src/sdk/index.ts +2 -0
- package/src/web3Sdk/abi/LBTC.json +407 -234
- package/src/web3Sdk/index.ts +1 -0
- package/src/web3Sdk/lbtcAddressConfig.ts +15 -4
- package/src/web3Sdk/unstakeLBTC/unstakeLBTC.ts +2 -2
- package/src/web3Sdk/utils/getLbtcTokenContract.ts +9 -5
package/src/web3Sdk/index.ts
CHANGED
|
@@ -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
|
|
6
|
+
const stageConfig: LbtcTokenConfig = {
|
|
7
7
|
[OChainId.holesky]: '0xED7bfd5C1790576105Af4649817f6d35A75CD818',
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const
|
|
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
|
-
|
|
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.
|
|
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 {
|
|
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
|
-
|
|
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');
|