@lombard.finance/sdk 3.4.0 → 3.5.7
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 +57 -153
- package/dist/ccip.cjs +1 -2
- package/dist/ccip.js +50 -48
- package/dist/index.cjs +1 -2
- package/dist/index.js +88 -75
- package/dist/index2.cjs +65 -63
- package/dist/index2.js +12028 -10438
- package/package.json +1 -1
- package/src/api-functions/generateDepositBtcAddress/generateDepositBtcAddress.stories.tsx +7 -0
- package/src/api-functions/generateDepositBtcAddress/generateDepositBtcAddress.ts +83 -4
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddress.stories.tsx +7 -8
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddress.ts +66 -3
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddresses.stories.tsx +4 -0
- package/src/api-functions/getDepositsByAddress/getDepositsByAddress.ts +4 -2
- package/src/api-functions/getLBTCExchangeRate/get-exchange-ratio.stories.tsx +47 -0
- package/src/api-functions/getLBTCExchangeRate/get-exchange-ratio.ts +58 -0
- package/src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.stories.tsx +3 -1
- package/src/api-functions/getNetworkFeeSignature/getNetworkFeeSignature.stories.tsx +2 -0
- package/src/api-functions/getUnstakesByAddress/getUnstakesByAddress.ts +35 -6
- package/src/api-functions/getUnstakesByAddress/index.ts +5 -1
- package/src/bridge/lib/ccip-bridge.ts +1 -1
- package/src/bridge/lib/config.ts +119 -104
- package/src/clients/public-client.ts +9 -1
- package/src/clients/rpc-url-config.ts +28 -0
- package/src/common/api-config.ts +4 -3
- package/src/common/blockchain-identifier.ts +11 -0
- package/src/common/chains.stories.tsx +67 -0
- package/src/common/chains.ts +83 -0
- package/src/contract-functions/approveLBTC/approveLBTC.stories.tsx +2 -0
- package/src/contract-functions/claimLBTC/claimLBTC.stories.tsx +13 -4
- package/src/contract-functions/claimLBTC/claimLBTC.ts +50 -11
- package/src/contract-functions/getBasculeDepositStatus/getBasculeDepositStatus.ts +6 -4
- package/src/contract-functions/getLBTCMintingFee/getLBTCMintingFee.stories.tsx +7 -10
- package/src/contract-functions/getLBTCMintingFee/getLBTCMintingFee.tsx +45 -6
- package/src/contract-functions/getLBTCTotalSupply/getLBTCTotalSupply.stories.tsx +3 -1
- package/src/contract-functions/getLBTCTotalSupply/getLBTCTotalSupply.ts +5 -4
- package/src/contract-functions/signNetworkFee/signNetworkFee.stories.tsx +2 -0
- package/src/contract-functions/unstakeLBTC/unstakeLBTC.stories.tsx +15 -4
- package/src/contract-functions/unstakeLBTC/unstakeLBTC.ts +55 -13
- package/src/index.ts +2 -0
- package/src/metrics/get-lbtc-stats.stories.tsx +6 -1
- package/src/metrics/get-lbtc-stats.ts +46 -9
- package/src/metrics/get-rewards-info.stories.tsx +57 -0
- package/src/metrics/get-rewards-info.ts +35 -0
- package/src/stories/arg-types.ts +34 -0
- package/src/stories/components/CodeBlock/CodeBlock.tsx +1 -0
- package/src/stories/components/Spinner/Spinner.tsx +2 -0
- package/src/stories/components/decorators/wagmi-decorator.tsx +5 -0
- package/src/stories/hooks/useConnection.ts +3 -13
- package/src/tokens/abi/BTCK_ABI.ts +1092 -0
- package/src/tokens/lbtc-addresses.ts +7 -0
- package/src/tokens/token-addresses.ts +102 -10
- package/src/tokens/tokens.ts +29 -18
- package/src/utils/env.ts +7 -0
- package/src/utils/err.ts +14 -0
- package/src/utils/gas.ts +36 -0
- package/src/vaults/lib/metrics/get-vault-tvl.ts +1 -0
- package/dist/ccip.cjs.map +0 -1
- package/dist/ccip.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index2.cjs.map +0 -1
- package/dist/index2.js.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { getApiConfig } from '../common/api-config';
|
|
3
|
+
import { IEnvParam } from '../common/parameters';
|
|
4
|
+
import { Address } from 'viem';
|
|
5
|
+
|
|
6
|
+
type Response = {
|
|
7
|
+
type: 'BALANCE_TYPE_DEFI';
|
|
8
|
+
total_lbtc_balance: number;
|
|
9
|
+
total_lbtc_balance_cost: number;
|
|
10
|
+
total_rewards: number;
|
|
11
|
+
total_rewards_cost: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the rewards info acquired by provided account address
|
|
16
|
+
*
|
|
17
|
+
* @experimental This function is not ready to be used in prod environment and will result with static and dummy data. Please do not rely on the data it returns.
|
|
18
|
+
*/
|
|
19
|
+
export async function getRewardsInfo({
|
|
20
|
+
account,
|
|
21
|
+
partnerId,
|
|
22
|
+
env,
|
|
23
|
+
}: { account: Address; partnerId?: string } & IEnvParam) {
|
|
24
|
+
const { baseApiUrl } = getApiConfig(env);
|
|
25
|
+
|
|
26
|
+
const url = `${baseApiUrl}/api/v1/rewards/${account}?partnerId=${partnerId || ''}`;
|
|
27
|
+
const { data } = await axios.get<Response>(url);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
type: data.type,
|
|
31
|
+
totalLbtcBalance: data.total_lbtc_balance,
|
|
32
|
+
totalRewards: data.total_rewards,
|
|
33
|
+
totalRewardsCost: data.total_rewards_cost,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ArgTypes } from 'storybook/internal/types';
|
|
2
|
+
import { ChainId } from '../common/chains';
|
|
3
|
+
import { Env } from '@lombard.finance/sdk-common';
|
|
4
|
+
import { Token } from '../tokens/token-addresses';
|
|
5
|
+
|
|
6
|
+
export const chainSelector: Partial<ArgTypes> = {
|
|
7
|
+
chainId: {
|
|
8
|
+
mapping: ChainId,
|
|
9
|
+
options: Object.keys(ChainId),
|
|
10
|
+
control: { type: 'select' },
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const envSelector: Partial<ArgTypes> = {
|
|
15
|
+
env: {
|
|
16
|
+
mapping: Env,
|
|
17
|
+
options: Object.keys(Env),
|
|
18
|
+
control: { type: 'select' },
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const makeTokenSelector = (tokens?: Token[]): Partial<ArgTypes> => ({
|
|
23
|
+
token: {
|
|
24
|
+
mapping: Token,
|
|
25
|
+
options: Object.keys(Token).filter(tk => {
|
|
26
|
+
if (!tokens) return true;
|
|
27
|
+
|
|
28
|
+
const entries = Object.entries(Token);
|
|
29
|
+
const keys = tokens.map(tv => entries.find(([, v]) => v === tv)?.[0]);
|
|
30
|
+
return keys.includes(tk);
|
|
31
|
+
}),
|
|
32
|
+
control: { type: 'select' },
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
swellchain,
|
|
20
20
|
} from 'viem/chains';
|
|
21
21
|
import { createConfig, http, WagmiProvider } from 'wagmi';
|
|
22
|
+
import { katana, katanaTatara } from '../../../common/chains';
|
|
22
23
|
|
|
23
24
|
const config = createConfig({
|
|
24
25
|
chains: [
|
|
@@ -27,6 +28,7 @@ const config = createConfig({
|
|
|
27
28
|
berachain,
|
|
28
29
|
bsc,
|
|
29
30
|
corn,
|
|
31
|
+
katana,
|
|
30
32
|
morph,
|
|
31
33
|
sonic,
|
|
32
34
|
swellchain,
|
|
@@ -35,6 +37,7 @@ const config = createConfig({
|
|
|
35
37
|
berachainTestnetbArtio,
|
|
36
38
|
bscTestnet,
|
|
37
39
|
holesky,
|
|
40
|
+
katanaTatara,
|
|
38
41
|
morphHolesky,
|
|
39
42
|
sepolia,
|
|
40
43
|
sonicBlazeTestnet,
|
|
@@ -45,6 +48,7 @@ const config = createConfig({
|
|
|
45
48
|
[berachain.id]: http(rpcUrlConfig[berachain.id]),
|
|
46
49
|
[bsc.id]: http(rpcUrlConfig[bsc.id]),
|
|
47
50
|
[corn.id]: http(rpcUrlConfig[corn.id]),
|
|
51
|
+
[katana.id]: http(rpcUrlConfig[katana.id]),
|
|
48
52
|
[morph.id]: http(rpcUrlConfig[morph.id]),
|
|
49
53
|
[sonic.id]: http(rpcUrlConfig[sonic.id]),
|
|
50
54
|
[swellchain.id]: http(rpcUrlConfig[swellchain.id]),
|
|
@@ -53,6 +57,7 @@ const config = createConfig({
|
|
|
53
57
|
[berachainTestnetbArtio.id]: http(rpcUrlConfig[berachainTestnetbArtio.id]),
|
|
54
58
|
[bscTestnet.id]: http(rpcUrlConfig[bscTestnet.id]),
|
|
55
59
|
[holesky.id]: http(rpcUrlConfig[holesky.id]),
|
|
60
|
+
[katanaTatara.id]: http(rpcUrlConfig[katanaTatara.id]),
|
|
56
61
|
[morphHolesky.id]: http(rpcUrlConfig[morphHolesky.id]),
|
|
57
62
|
[sepolia.id]: http(rpcUrlConfig[sepolia.id]),
|
|
58
63
|
[sonicBlazeTestnet.id]: http(rpcUrlConfig[sonicBlazeTestnet.id]),
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { ChainId } from '../../common/chains';
|
|
2
1
|
import {
|
|
3
2
|
Config,
|
|
4
|
-
Connector,
|
|
5
3
|
useAccount,
|
|
6
4
|
UseAccountReturnType,
|
|
7
5
|
useConnect as useWagmiConnect,
|
|
@@ -9,20 +7,12 @@ import {
|
|
|
9
7
|
} from 'wagmi';
|
|
10
8
|
import { injected } from 'wagmi/connectors';
|
|
11
9
|
import { useCallback, useEffect, useState } from 'react';
|
|
12
|
-
import {
|
|
10
|
+
import { EIP1193Provider } from 'viem';
|
|
11
|
+
import { ChainId } from '../../common/chains';
|
|
13
12
|
|
|
14
13
|
type CanPerformAction = {
|
|
15
|
-
account: {
|
|
16
|
-
address: Address;
|
|
17
|
-
addresses: readonly [Address, ...Address[]];
|
|
18
|
-
chain: Chain;
|
|
14
|
+
account: Extract<UseAccountReturnType<Config>, { status: 'connected' }> & {
|
|
19
15
|
chainId: ChainId;
|
|
20
|
-
connector: Connector;
|
|
21
|
-
isConnected: true;
|
|
22
|
-
isConnecting: false;
|
|
23
|
-
isDisconnected: false;
|
|
24
|
-
isReconnecting: false;
|
|
25
|
-
status: 'connected';
|
|
26
16
|
};
|
|
27
17
|
provider: EIP1193Provider;
|
|
28
18
|
};
|