@lombard.finance/sdk 3.1.0 → 3.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.
Files changed (76) hide show
  1. package/README.md +60 -1
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +73 -62
  4. package/dist/index2.cjs +62 -52
  5. package/dist/index2.cjs.map +1 -1
  6. package/dist/index2.js +8361 -12041
  7. package/dist/index2.js.map +1 -1
  8. package/package.json +35 -33
  9. package/src/api-functions/generateDepositBtcAddress/generateDepositBtcAddress.ts +4 -4
  10. package/src/api-functions/getDepositBtcAddress/getDepositBtcAddress.stories.tsx +8 -0
  11. package/src/api-functions/getDepositBtcAddress/getDepositBtcAddress.ts +3 -3
  12. package/src/api-functions/getDepositsByAddress/getDepositsByAddress.ts +8 -7
  13. package/src/api-functions/getUnstakesByAddress/getUnstakesByAddress.ts +5 -5
  14. package/src/api-functions/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +8 -0
  15. package/src/bridge/abi/CCIP_BRIDGE_ADAPTER_ABI.json +704 -0
  16. package/src/bridge/abi/OFT_BRIDGE_ADAPTER_ABI.json +912 -0
  17. package/src/bridge/index.ts +11 -0
  18. package/src/bridge/lib/bridge.stories.tsx +89 -0
  19. package/src/bridge/lib/bridge.ts +101 -0
  20. package/src/bridge/lib/ccip-bridge.stories.tsx +90 -0
  21. package/src/bridge/lib/ccip-bridge.ts +163 -0
  22. package/src/bridge/lib/config.ts +338 -0
  23. package/src/bridge/lib/oft-bridge.stories.tsx +89 -0
  24. package/src/bridge/lib/oft-bridge.ts +211 -0
  25. package/src/common/api-config.ts +8 -2
  26. package/src/common/blockchain-identifier.ts +32 -5
  27. package/src/common/chains.ts +13 -1
  28. package/src/common/contract-info.ts +8 -0
  29. package/src/contract-functions/approveLBTC/approveLBTC.stories.tsx +1 -1
  30. package/src/contract-functions/approveLBTC/approveLBTC.ts +3 -2
  31. package/src/contract-functions/claimLBTC/claimLBTC.ts +3 -2
  32. package/src/contract-functions/getBasculeDepositStatus/getBasculeDepositStatus.ts +10 -4
  33. package/src/contract-functions/getLBTCMintingFee/getLBTCMintingFee.tsx +14 -11
  34. package/src/contract-functions/getLBTCTotalSupply/getLBTCTotalSupply.ts +13 -9
  35. package/src/contract-functions/getPermitNonce/getPermitNonce.ts +16 -10
  36. package/src/contract-functions/getShareValue/getShareValue.stories.tsx +1 -1
  37. package/src/contract-functions/getShareValue/getShareValue.ts +1 -1
  38. package/src/contract-functions/getSharesByAddress/getSharesByAddress.stories.tsx +1 -1
  39. package/src/contract-functions/getSharesByAddress/getSharesByAddress.ts +1 -1
  40. package/src/contract-functions/getStakeAndBakeFee/getStakeAndBakeFee.stories.tsx +14 -1
  41. package/src/contract-functions/getStakeAndBakeFee/getStakeAndBakeFee.tsx +5 -1
  42. package/src/contract-functions/signNetworkFee/signNetworkFee.ts +3 -2
  43. package/src/contract-functions/signStakeAndBake/signStakeAndBake.stories.tsx +2 -1
  44. package/src/contract-functions/signStakeAndBake/signStakeAndBake.ts +8 -3
  45. package/src/contract-functions/unstakeLBTC/unstakeLBTC.ts +3 -2
  46. package/src/index.ts +26 -28
  47. package/src/metrics/get-lbtc-stats.stories.tsx +51 -0
  48. package/src/metrics/get-lbtc-stats.ts +38 -0
  49. package/src/rewards/lib/claim-reward.stories.tsx +1 -0
  50. package/src/rewards/lib/claim-reward.ts +5 -0
  51. package/src/rewards/lib/get-reward-signing-data.stories.tsx +1 -0
  52. package/src/rewards/lib/get-reward-signing-data.ts +4 -0
  53. package/src/tokens/abi/LBTC_ABI.json +1760 -1760
  54. package/src/tokens/abi/LBTC_ABI.ts +1761 -0
  55. package/src/tokens/lbtc-addresses.ts +1 -0
  56. package/src/tokens/token-addresses.ts +32 -0
  57. package/src/tokens/tokens.ts +59 -50
  58. package/src/utils/numbers.ts +3 -0
  59. package/src/vaults/index.ts +35 -176
  60. package/src/vaults/lib/config.ts +196 -0
  61. package/src/vaults/lib/metrics/get-vault-apy.stories.tsx +57 -0
  62. package/src/vaults/lib/metrics/get-vault-apy.ts +132 -0
  63. package/src/vaults/lib/{get-vault-points.stories.tsx → metrics/get-vault-points.stories.tsx} +8 -8
  64. package/src/vaults/lib/{get-vault-points.ts → metrics/get-vault-points.ts} +1 -1
  65. package/src/vaults/lib/metrics/get-vault-tvl.stories.tsx +57 -0
  66. package/src/vaults/lib/metrics/get-vault-tvl.ts +119 -0
  67. package/src/vaults/lib/{cancel-withdraw.stories.tsx → ops/cancel-withdraw.stories.tsx} +9 -9
  68. package/src/vaults/lib/{deposit.stories.tsx → ops/deposit.stories.tsx} +9 -9
  69. package/src/vaults/lib/{deposit.ts → ops/deposit.ts} +10 -10
  70. package/src/vaults/lib/{get-vault-deposits.stories.tsx → ops/get-vault-deposits.stories.tsx} +9 -9
  71. package/src/vaults/lib/{get-vault-deposits.ts → ops/get-vault-deposits.ts} +5 -5
  72. package/src/vaults/lib/{get-vault-withdrawals.stories.tsx → ops/get-vault-withdrawals.stories.tsx} +9 -9
  73. package/src/vaults/lib/{get-vault-withdrawals.ts → ops/get-vault-withdrawals.ts} +5 -5
  74. package/src/vaults/lib/{withdraw.stories.tsx → ops/withdraw.stories.tsx} +9 -9
  75. package/src/vaults/lib/{withdraw.ts → ops/withdraw.ts} +12 -12
  76. package/src/tokens/lbtc-contract.ts +0 -89
@@ -0,0 +1,132 @@
1
+ import axios from 'axios';
2
+ import { ChainId } from '../../../common/chains';
3
+ import { isVedaVaultChain, Vault, VAULTS, VedaVaultChain } from '../config';
4
+ import BigNumber from 'bignumber.js';
5
+ import { orderBy } from '../../../utils/array';
6
+
7
+ export type GetVaultApyParameters = {
8
+ aggregationPeriod?: 7 | 14 | 30;
9
+ chainId?: ChainId;
10
+ vaultKey?: Vault;
11
+ };
12
+
13
+ /** Gets the trailing APY performance history. */
14
+ export async function getVaultApy({
15
+ aggregationPeriod = 7,
16
+ chainId = ChainId.ethereum,
17
+ vaultKey = Vault.Veda,
18
+ }: GetVaultApyParameters) {
19
+ const response = await getVaultPerformance({
20
+ aggregationPeriod,
21
+ chainId,
22
+ vaultKey,
23
+ });
24
+
25
+ const apys = response.Response.map(r => {
26
+ const allocations = Object.entries(r.chain_allocation)
27
+ .map(([network, value]) => [
28
+ NETWORK_TO_CHAIN_ID_MAP[network],
29
+ BigNumber(value),
30
+ ])
31
+ .reduce(
32
+ (acc, cur) => {
33
+ const [chainId, value] = cur as [ChainId, BigNumber];
34
+ acc[chainId] = value;
35
+ return acc;
36
+ },
37
+ {} as Partial<Record<ChainId, BigNumber>>,
38
+ );
39
+
40
+ const breakdown = r.real_apy_breakdown.map(b => ({
41
+ allocations: BigNumber(b.allocation),
42
+ apy: BigNumber(b.apy),
43
+ chainId: NETWORK_TO_CHAIN_ID_MAP[b.chain],
44
+ protocol: b.protocol,
45
+ }));
46
+
47
+ return {
48
+ apy: BigNumber(r.apy),
49
+ allocations,
50
+ breakdown,
51
+ timestamp: new Date(r.timestamp),
52
+ };
53
+ });
54
+
55
+ return orderBy(apys, a => a.timestamp.getTime(), 'desc');
56
+ }
57
+
58
+ type GetVaultPerformanceParameters = {
59
+ aggregationPeriod?: 7 | 14 | 30;
60
+ chainId: ChainId;
61
+ vaultKey?: Vault;
62
+ };
63
+
64
+ type Response = {
65
+ Response: {
66
+ aggregation_period: string;
67
+ apy: number;
68
+ chain_allocation: { [network: string]: number };
69
+ fees: number;
70
+ // omitted prop: global_apy_breakdown
71
+ // omitted prop: maturity_apy_breakdown
72
+ real_apy_breakdown: {
73
+ allocation: number;
74
+ apy: number;
75
+ /** network */
76
+ chain: string;
77
+ protocol: string;
78
+ }[];
79
+ timestamp: string;
80
+ }[];
81
+ };
82
+
83
+ const CHAIN_ID_TO_NETWORK_MAP: Record<VedaVaultChain, string> = {
84
+ // NOTE: For now only `ethereum` is supported by the API.
85
+ [ChainId.ethereum]: 'ethereum',
86
+
87
+ // NOTE: The following networks are not supported for now. The API is supposed
88
+ // to return the aggregated data for all vault chains.
89
+ [ChainId.base]: 'base',
90
+ [ChainId.binanceSmartChain]: 'bnb',
91
+ [ChainId.corn]: 'corn',
92
+ };
93
+
94
+ const NETWORK_TO_CHAIN_ID_MAP: Record<string, VedaVaultChain> = {
95
+ ethereum: ChainId.ethereum,
96
+ base: ChainId.base,
97
+ bnb: ChainId.binanceSmartChain,
98
+ corn: ChainId.corn,
99
+ };
100
+
101
+ /**
102
+ * Gets the raw response of the performance apy api for the provided vault.
103
+ */
104
+ async function getVaultPerformance({
105
+ aggregationPeriod = 7,
106
+ chainId,
107
+ vaultKey = Vault.Veda,
108
+ }: GetVaultPerformanceParameters) {
109
+ const vault = VAULTS[vaultKey];
110
+ if (!vault) {
111
+ throw new Error(`Unknown vault key: ${vaultKey}`);
112
+ }
113
+
114
+ if (!isVedaVaultChain(chainId)) {
115
+ throw new Error(
116
+ `Unsupported chain id: ${chainId}. Please switch to one of the supported chains: ${vault.chains.join(', ')}`,
117
+ );
118
+ }
119
+
120
+ const network = CHAIN_ID_TO_NETWORK_MAP[chainId];
121
+ if (network !== 'ethereum') {
122
+ throw new Error(
123
+ `Unsupported network ${network}. Please switch to 'ethereum'.`,
124
+ );
125
+ }
126
+
127
+ const url = `https://api.sevenseas.capital/performance/${network}/${vault.vaultContract.address}?historical=true&aggregation_period=${aggregationPeriod}`;
128
+
129
+ const { data } = await axios.get<Response>(url);
130
+
131
+ return data;
132
+ }
@@ -1,18 +1,18 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { Button } from '../../stories/components/Button';
3
- import { CodeBlock } from '../../stories/components/CodeBlock';
4
- import useQuery from '../../stories/hooks/useQuery';
2
+ import { Button } from '../../../stories/components/Button';
3
+ import { CodeBlock } from '../../../stories/components/CodeBlock';
4
+ import useQuery from '../../../stories/hooks/useQuery';
5
5
  import {
6
6
  functionType,
7
7
  wagmiDecorator,
8
- } from '../../stories/components/decorators';
9
- import { Vault } from '..';
10
- import { ErrorBlock } from '../../stories/components/error-block';
11
- import { EXAMPLE_EVM_ADDRESS } from '../../stories/constants';
8
+ } from '../../../stories/components/decorators';
9
+ import { Vault } from '../config';
10
+ import { ErrorBlock } from '../../../stories/components/error-block';
11
+ import { EXAMPLE_EVM_ADDRESS } from '../../../stories/constants';
12
12
  import { getVaultPoints, GetVaultPointsParameters } from './get-vault-points';
13
13
 
14
14
  const meta = {
15
- title: 'vault/getVaultPoints',
15
+ title: 'vault/metrics/getVaultPoints',
16
16
  component: StoryView,
17
17
  tags: ['autodocs'],
18
18
  decorators: [wagmiDecorator, functionType('api-get')],
@@ -1,5 +1,5 @@
1
1
  import { Address } from 'viem';
2
- import { Vault, VAULTS } from '..';
2
+ import { Vault, VAULTS } from '../config';
3
3
  import axios from 'axios';
4
4
 
5
5
  export type GetVaultPointsParameters = {
@@ -0,0 +1,57 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Button } from '../../../stories/components/Button';
3
+ import { CodeBlock } from '../../../stories/components/CodeBlock';
4
+ import useQuery from '../../../stories/hooks/useQuery';
5
+ import {
6
+ functionType,
7
+ wagmiDecorator,
8
+ } from '../../../stories/components/decorators';
9
+ import { Vault } from '../config';
10
+ import { ErrorBlock } from '../../../stories/components/error-block';
11
+ import { getVaultTVL, GetVaultTVLParameters } from './get-vault-tvl';
12
+
13
+ const meta = {
14
+ title: 'vault/metrics/getVaultTVL',
15
+ component: StoryView,
16
+ tags: ['autodocs'],
17
+ decorators: [wagmiDecorator, functionType('api-get')],
18
+ } satisfies Meta<typeof StoryView>;
19
+
20
+ export default meta;
21
+
22
+ type Story = StoryObj<typeof meta>;
23
+
24
+ export const WithParams: Story = {
25
+ args: {
26
+ vaultKey: Vault.Veda,
27
+ },
28
+ };
29
+
30
+ type SignNetworkFeeProps = GetVaultTVLParameters;
31
+
32
+ export function StoryView(props: SignNetworkFeeProps) {
33
+ const request = async () => {
34
+ return getVaultTVL({
35
+ ...props,
36
+ });
37
+ };
38
+
39
+ const { data, error, isLoading, refetch } = useQuery(request, [], false);
40
+
41
+ return (
42
+ <>
43
+ <p>This function gets the TVL of the DeFi vault.</p>
44
+
45
+ <Button
46
+ onClick={refetch}
47
+ disabled={isLoading}
48
+ isLoading={isLoading}
49
+ actionName={getVaultTVL.name}
50
+ />
51
+
52
+ <ErrorBlock>{error}</ErrorBlock>
53
+
54
+ <CodeBlock text={data} />
55
+ </>
56
+ );
57
+ }
@@ -0,0 +1,119 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { makePublicClient } from '../../../clients/public-client';
3
+ import { Vault, VAULTS, VedaVaultChain } from '../config';
4
+ import {
5
+ fromBaseDenomination,
6
+ getTokenContractInfo,
7
+ retrieveTokenProperties,
8
+ } from '../../../tokens/tokens';
9
+ import { Token } from '../../../tokens/token-addresses';
10
+ import { extractChain, PublicClient } from 'viem';
11
+ import * as chains from 'viem/chains';
12
+ import { IEnvParam } from '../../../common/parameters';
13
+ import { getApiConfig } from '../../../common/api-config';
14
+ import axios from 'axios';
15
+
16
+ export type GetVaultBtcHolding = {
17
+ vaultKey?: Vault;
18
+ rpcUrls?: Record<VedaVaultChain, string>;
19
+ };
20
+ export async function getVaultBtcHolding({
21
+ vaultKey = Vault.Veda,
22
+ rpcUrls,
23
+ }: GetVaultBtcHolding) {
24
+ const vault = VAULTS[vaultKey];
25
+ if (!vault) {
26
+ throw new Error(`Unknown vault key: ${vaultKey}`);
27
+ }
28
+
29
+ const clients: Partial<Record<VedaVaultChain, PublicClient>> = {};
30
+ for (const chainId of vault.chains) {
31
+ const publicClient = makePublicClient({
32
+ chainId: chainId,
33
+ rpcUrl: rpcUrls?.[chainId],
34
+ });
35
+ clients[chainId] = publicClient;
36
+ }
37
+
38
+ const balances = [];
39
+
40
+ for (const [token, chainIds] of Object.entries(vault.tokens)) {
41
+ for (const chainId of chainIds) {
42
+ const tokenContract = getTokenContractInfo(token as Token, chainId);
43
+ const publicClient = clients[chainId];
44
+ if (!publicClient) continue;
45
+
46
+ const tokenInfo = await retrieveTokenProperties(
47
+ publicClient,
48
+ tokenContract,
49
+ );
50
+
51
+ if (!tokenInfo) continue;
52
+
53
+ const balanceRaw = await publicClient.readContract({
54
+ abi: tokenContract.abi,
55
+ address: tokenContract.address,
56
+ functionName: 'balanceOf',
57
+ args: [vault.vaultContract.address],
58
+ });
59
+
60
+ const balance = fromBaseDenomination(
61
+ balanceRaw ? String(balanceRaw) : 0,
62
+ tokenInfo.decimals,
63
+ );
64
+
65
+ const ch = extractChain({ chains: Object.values(chains), id: chainId });
66
+ console.info(`Balance of ${token} on ${ch.name}: ${balance}`);
67
+
68
+ balances.push(balance);
69
+ }
70
+ }
71
+
72
+ return BigNumber.sum.apply(null, balances);
73
+ }
74
+
75
+ export type GetVaultTVLParameters = {
76
+ vaultKey?: Vault;
77
+ } & IEnvParam;
78
+
79
+ type DuneQueryResult = {
80
+ net_btc_balance: number;
81
+ price: number;
82
+ vault_tvl: number;
83
+ };
84
+
85
+ type Response = {
86
+ /** The TVL represented in BTC locked in the vault */
87
+ btcBalance: BigNumber;
88
+ /** The BTC price in US dollars */
89
+ btcPrice: BigNumber;
90
+ /** The TVL represented us US dollars */
91
+ tvl: BigNumber;
92
+ };
93
+ export async function getVaultTVL({
94
+ vaultKey = Vault.Veda,
95
+ env,
96
+ }: GetVaultTVLParameters) {
97
+ const vault = VAULTS[vaultKey];
98
+ if (!vault) {
99
+ throw new Error(`Unknown vault key: ${vaultKey}`);
100
+ }
101
+
102
+ const { bffApiUrl } = getApiConfig(env);
103
+ if (!bffApiUrl) {
104
+ throw new Error(
105
+ `Could not determine API endpoint for provided environment: ${env}`,
106
+ );
107
+ }
108
+
109
+ const url = `${bffApiUrl}/dune-api/query/vault-tvl`;
110
+ const { data } = await axios.get<DuneQueryResult>(url);
111
+
112
+ const response: Response = {
113
+ btcBalance: BigNumber(data.net_btc_balance),
114
+ btcPrice: BigNumber(data.price),
115
+ tvl: BigNumber(data.vault_tvl),
116
+ };
117
+
118
+ return response;
119
+ }
@@ -1,22 +1,22 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { Button } from '../../stories/components/Button';
3
- import { CodeBlock } from '../../stories/components/CodeBlock';
2
+ import { Button } from '../../../stories/components/Button';
3
+ import { CodeBlock } from '../../../stories/components/CodeBlock';
4
4
  import {
5
5
  canPerformAction,
6
6
  useConnection,
7
- } from '../../stories/hooks/useConnection';
8
- import useQuery from '../../stories/hooks/useQuery';
9
- import { ConnectButton } from '../../stories/components/ConnectButton';
7
+ } from '../../../stories/hooks/useConnection';
8
+ import useQuery from '../../../stories/hooks/useQuery';
9
+ import { ConnectButton } from '../../../stories/components/ConnectButton';
10
10
  import {
11
11
  functionType,
12
12
  wagmiDecorator,
13
- } from '../../stories/components/decorators';
14
- import { Vault } from '..';
15
- import { ErrorBlock } from '../../stories/components/error-block';
13
+ } from '../../../stories/components/decorators';
14
+ import { Vault } from '../config';
15
+ import { ErrorBlock } from '../../../stories/components/error-block';
16
16
  import { CancelWithdrawParameters, cancelWithdraw } from './withdraw';
17
17
 
18
18
  const meta = {
19
- title: 'vault/cancelWithdraw',
19
+ title: 'vault/ops/cancelWithdraw',
20
20
  component: StoryView,
21
21
  tags: ['autodocs'],
22
22
  decorators: [wagmiDecorator, functionType('write')],
@@ -1,22 +1,22 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { Button } from '../../stories/components/Button';
3
- import { CodeBlock } from '../../stories/components/CodeBlock';
2
+ import { Button } from '../../../stories/components/Button';
3
+ import { CodeBlock } from '../../../stories/components/CodeBlock';
4
4
  import {
5
5
  canPerformAction,
6
6
  useConnection,
7
- } from '../../stories/hooks/useConnection';
8
- import useQuery from '../../stories/hooks/useQuery';
9
- import { ConnectButton } from '../../stories/components/ConnectButton';
7
+ } from '../../../stories/hooks/useConnection';
8
+ import useQuery from '../../../stories/hooks/useQuery';
9
+ import { ConnectButton } from '../../../stories/components/ConnectButton';
10
10
  import {
11
11
  functionType,
12
12
  wagmiDecorator,
13
- } from '../../stories/components/decorators';
13
+ } from '../../../stories/components/decorators';
14
14
  import { deposit, DepositParameters } from './deposit';
15
- import { Vault } from '..';
16
- import { ErrorBlock } from '../../stories/components/error-block';
15
+ import { Vault } from '../config';
16
+ import { ErrorBlock } from '../../../stories/components/error-block';
17
17
 
18
18
  const meta = {
19
- title: 'vault/deposit',
19
+ title: 'vault/ops/deposit',
20
20
  component: StoryView,
21
21
  tags: ['autodocs'],
22
22
  decorators: [wagmiDecorator, functionType('write')],
@@ -1,17 +1,17 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import { isVedaVaultChain, Vault, VAULTS } from '..';
3
- import { CommonWriteParameters } from '../../common/parameters';
4
- import { makePublicClient } from '../../clients/public-client';
5
- import { makeWalletClient } from '../../clients/wallet-client';
6
- import toBigInt from '../../utils/numbers';
7
- import { CHAIN_ID_TO_VIEM_CHAIN_MAP } from '../../common/chains';
8
- import { getErrorMessage } from '../../utils/err';
2
+ import { isVedaVaultChain, Vault, VAULTS } from '../config';
3
+ import { CommonWriteParameters } from '../../../common/parameters';
4
+ import { makePublicClient } from '../../../clients/public-client';
5
+ import { makeWalletClient } from '../../../clients/wallet-client';
6
+ import toBigInt from '../../../utils/numbers';
7
+ import { CHAIN_ID_TO_VIEM_CHAIN_MAP } from '../../../common/chains';
8
+ import { getErrorMessage } from '../../../utils/err';
9
9
  import {
10
10
  fromBaseDenomination,
11
11
  getTokenInfo,
12
12
  toBaseDenomination,
13
- Token,
14
- } from '../../tokens/tokens';
13
+ } from '../../../tokens/tokens';
14
+ import { Token } from '../../../tokens/token-addresses';
15
15
 
16
16
  export type DepositParameters = {
17
17
  /** The amount to be deposited into the DeFi vault. */
@@ -45,7 +45,7 @@ export type DepositParameters = {
45
45
  export async function deposit({
46
46
  amount: amountRaw,
47
47
  approve = true,
48
- token = 'LBTC',
48
+ token = Token.LBTC,
49
49
  vaultKey = Vault.Veda,
50
50
  account,
51
51
  chainId,
@@ -1,22 +1,22 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { Button } from '../../stories/components/Button';
3
- import { CodeBlock } from '../../stories/components/CodeBlock';
4
- import useQuery from '../../stories/hooks/useQuery';
2
+ import { Button } from '../../../stories/components/Button';
3
+ import { CodeBlock } from '../../../stories/components/CodeBlock';
4
+ import useQuery from '../../../stories/hooks/useQuery';
5
5
  import {
6
6
  functionType,
7
7
  wagmiDecorator,
8
- } from '../../stories/components/decorators';
9
- import { Vault } from '..';
10
- import { ErrorBlock } from '../../stories/components/error-block';
8
+ } from '../../../stories/components/decorators';
9
+ import { Vault } from '../config';
10
+ import { ErrorBlock } from '../../../stories/components/error-block';
11
11
  import {
12
12
  getVaultDeposits,
13
13
  GetVaultDepositsParameters,
14
14
  } from './get-vault-deposits';
15
- import { EXAMPLE_EVM_ADDRESS } from '../../stories/constants';
16
- import { ChainId } from '../../common/chains';
15
+ import { EXAMPLE_EVM_ADDRESS } from '../../../stories/constants';
16
+ import { ChainId } from '../../../common/chains';
17
17
 
18
18
  const meta = {
19
- title: 'vault/getVaultDeposits',
19
+ title: 'vault/ops/getVaultDeposits',
20
20
  component: StoryView,
21
21
  tags: ['autodocs'],
22
22
  decorators: [wagmiDecorator, functionType('api-get')],
@@ -1,5 +1,5 @@
1
1
  import { Address, Hash } from 'viem';
2
- import { ChainId } from '../../common/chains';
2
+ import { ChainId } from '../../../common/chains';
3
3
  import {
4
4
  isVedaVaultChain,
5
5
  NETWORK_TO_VEDA_VAULT_CHAIN_MAP,
@@ -7,16 +7,16 @@ import {
7
7
  VAULTS,
8
8
  VEDA_VAULT_CHAIN_TO_NETWORK_MAP,
9
9
  VedaVaultChain,
10
- } from '..';
10
+ } from '../config';
11
11
  import axios from 'axios';
12
12
  import BigNumber from 'bignumber.js';
13
13
  import {
14
14
  fromBaseDenomination,
15
15
  getAssetInfo,
16
16
  TokenInfo,
17
- } from '../../tokens/tokens';
18
- import { ensureHex } from '../../utils/hex';
19
- import { orderBy, unique } from '../../utils/array';
17
+ } from '../../../tokens/tokens';
18
+ import { ensureHex } from '../../../utils/hex';
19
+ import { orderBy, unique } from '../../../utils/array';
20
20
 
21
21
  const DEPOSITS_URL =
22
22
  'https://api.sevenseas.capital/deposits/{network}/{vault}/{account}';
@@ -1,22 +1,22 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { Button } from '../../stories/components/Button';
3
- import { CodeBlock } from '../../stories/components/CodeBlock';
4
- import useQuery from '../../stories/hooks/useQuery';
2
+ import { Button } from '../../../stories/components/Button';
3
+ import { CodeBlock } from '../../../stories/components/CodeBlock';
4
+ import useQuery from '../../../stories/hooks/useQuery';
5
5
  import {
6
6
  functionType,
7
7
  wagmiDecorator,
8
- } from '../../stories/components/decorators';
9
- import { Vault } from '..';
10
- import { ErrorBlock } from '../../stories/components/error-block';
11
- import { EXAMPLE_EVM_ADDRESS } from '../../stories/constants';
12
- import { ChainId } from '../../common/chains';
8
+ } from '../../../stories/components/decorators';
9
+ import { Vault } from '../config';
10
+ import { ErrorBlock } from '../../../stories/components/error-block';
11
+ import { EXAMPLE_EVM_ADDRESS } from '../../../stories/constants';
12
+ import { ChainId } from '../../../common/chains';
13
13
  import {
14
14
  getVaultWithdrawals,
15
15
  GetVaultWithdrawalsParameters,
16
16
  } from './get-vault-withdrawals';
17
17
 
18
18
  const meta = {
19
- title: 'vault/getVaultWithdrawals',
19
+ title: 'vault/ops/getVaultWithdrawals',
20
20
  component: StoryView,
21
21
  tags: ['autodocs'],
22
22
  decorators: [wagmiDecorator, functionType('api-get')],
@@ -4,17 +4,17 @@ import {
4
4
  Vault,
5
5
  VAULTS,
6
6
  VEDA_VAULT_CHAIN_TO_NETWORK_MAP,
7
- } from '..';
8
- import { ChainId } from '../../common/chains';
7
+ } from '../config';
8
+ import { ChainId } from '../../../common/chains';
9
9
  import {
10
10
  fromBaseDenomination,
11
11
  getAssetInfo,
12
12
  TokenInfo,
13
- } from '../../tokens/tokens';
13
+ } from '../../../tokens/tokens';
14
14
  import BigNumber from 'bignumber.js';
15
15
  import axios from 'axios';
16
- import { orderBy, unique } from '../../utils/array';
17
- import { ensureHex } from '../../utils/hex';
16
+ import { orderBy, unique } from '../../../utils/array';
17
+ import { ensureHex } from '../../../utils/hex';
18
18
 
19
19
  export type GetVaultWithdrawalsParameters = {
20
20
  account: Address;
@@ -1,22 +1,22 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
- import { Button } from '../../stories/components/Button';
3
- import { CodeBlock } from '../../stories/components/CodeBlock';
2
+ import { Button } from '../../../stories/components/Button';
3
+ import { CodeBlock } from '../../../stories/components/CodeBlock';
4
4
  import {
5
5
  canPerformAction,
6
6
  useConnection,
7
- } from '../../stories/hooks/useConnection';
8
- import useQuery from '../../stories/hooks/useQuery';
9
- import { ConnectButton } from '../../stories/components/ConnectButton';
7
+ } from '../../../stories/hooks/useConnection';
8
+ import useQuery from '../../../stories/hooks/useQuery';
9
+ import { ConnectButton } from '../../../stories/components/ConnectButton';
10
10
  import {
11
11
  functionType,
12
12
  wagmiDecorator,
13
- } from '../../stories/components/decorators';
14
- import { Vault } from '..';
15
- import { ErrorBlock } from '../../stories/components/error-block';
13
+ } from '../../../stories/components/decorators';
14
+ import { Vault } from '../config';
15
+ import { ErrorBlock } from '../../../stories/components/error-block';
16
16
  import { queueWithdraw, QueueWithdrawParameters } from './withdraw';
17
17
 
18
18
  const meta = {
19
- title: 'vault/withdraw',
19
+ title: 'vault/ops/withdraw',
20
20
  component: StoryView,
21
21
  tags: ['autodocs'],
22
22
  decorators: [wagmiDecorator, functionType('write')],
@@ -1,18 +1,18 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import { isVedaVaultChain, Vault, VAULTS } from '..';
3
- import { CommonWriteParameters } from '../../common/parameters';
4
- import { makePublicClient } from '../../clients/public-client';
5
- import { makeWalletClient } from '../../clients/wallet-client';
2
+ import { isVedaVaultChain, Vault, VAULTS } from '../config';
3
+ import { CommonWriteParameters } from '../../../common/parameters';
4
+ import { makePublicClient } from '../../../clients/public-client';
5
+ import { makeWalletClient } from '../../../clients/wallet-client';
6
6
  import {
7
7
  fromBaseDenomination,
8
8
  getTokenInfo,
9
9
  toBaseDenomination,
10
- Token,
11
- } from '../../tokens/tokens';
12
- import toBigInt from '../../utils/numbers';
13
- import { CHAIN_ID_TO_VIEM_CHAIN_MAP } from '../../common/chains';
14
- import { getErrorMessage } from '../../utils/err';
15
- import { DAY } from '../../utils/time';
10
+ } from '../../../tokens/tokens';
11
+ import toBigInt from '../../../utils/numbers';
12
+ import { CHAIN_ID_TO_VIEM_CHAIN_MAP } from '../../../common/chains';
13
+ import { getErrorMessage } from '../../../utils/err';
14
+ import { DAY } from '../../../utils/time';
15
+ import { Token } from '../../../tokens/token-addresses';
16
16
 
17
17
  export type QueueWithdrawParameters = {
18
18
  /** The amount to be withdrawn from the DeFi vault. */
@@ -46,7 +46,7 @@ export type QueueWithdrawParameters = {
46
46
  export async function queueWithdraw({
47
47
  amount: amountRaw,
48
48
  approve = true,
49
- token = 'LBTC',
49
+ token = Token.LBTC,
50
50
  vaultKey = Vault.Veda,
51
51
  account,
52
52
  chainId,
@@ -178,7 +178,7 @@ export type CancelWithdrawParameters = Pick<
178
178
  * @returns
179
179
  */
180
180
  export async function cancelWithdraw({
181
- token = 'LBTC',
181
+ token = Token.LBTC,
182
182
  vaultKey = Vault.Veda,
183
183
  account,
184
184
  chainId,