@lombard.finance/sdk 3.6.0 → 3.6.1
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 +4 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +83 -85
- package/dist/index2.cjs +47 -47
- package/dist/index2.js +3060 -3001
- package/package.json +1 -1
- package/src/api-functions/generateDepositBtcAddress/generateDepositBtcAddress.stories.tsx +5 -5
- package/src/api-functions/generateDepositBtcAddress/generateDepositBtcAddress.ts +1 -1
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddress.stories.tsx +5 -5
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddress.ts +1 -1
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddresses.stories.tsx +4 -4
- package/src/api-functions/getDepositsByAddress/getDepositsByAddress.stories.tsx +3 -3
- package/src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.stories.tsx +5 -5
- package/src/api-functions/getLBTCExchangeRate/getLBTCExchangeRate.ts +4 -4
- package/src/api-functions/getNetworkFeeSignature/getNetworkFeeSignature.stories.tsx +6 -6
- package/src/api-functions/getNetworkFeeSignature/getNetworkFeeSignature.ts +2 -2
- package/src/api-functions/getPointsByAddress/getPointsByAddress.stories.tsx +3 -3
- package/src/api-functions/getPointsByAddress/getPointsByAddress.ts +2 -2
- package/src/api-functions/getUnstakesByAddress/getUnstakesByAddress.stories.tsx +3 -3
- package/src/api-functions/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +4 -4
- package/src/api-functions/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.ts +2 -2
- package/src/api-functions/setReferral/setReferral.ts +1 -1
- package/src/api-functions/storeNetworkFeeSignature/storeNetworkFeeSignature.stories.tsx +3 -3
- package/src/api-functions/storeNetworkFeeSignature/storeNetworkFeeSignature.ts +1 -1
- package/src/api-functions/storeStakeAndBakeSignature/storeStakeAndBakeSignature.stories.tsx +1 -1
- package/src/api-functions/storeStakeAndBakeSignature/storeStakeAndBakeSignature.ts +1 -1
- package/src/bridge/lib/bridge.stories.tsx +7 -7
- package/src/bridge/lib/bridge.ts +3 -3
- package/src/bridge/lib/ccip-bridge.stories.tsx +7 -7
- package/src/bridge/lib/ccip-bridge.ts +11 -11
- package/src/clients/public-client.ts +3 -3
- package/src/clients/wallet-client.ts +3 -3
- package/src/common/parameters.ts +1 -1
- package/src/contract-functions/approveLBTC/approveLBTC.stories.tsx +10 -10
- package/src/contract-functions/approveLBTC/approveLBTC.ts +7 -7
- package/src/contract-functions/claimLBTC/claimLBTC.stories.tsx +8 -8
- package/src/contract-functions/claimLBTC/claimLBTC.ts +11 -12
- package/src/contract-functions/getBasculeDepositStatus/getBasculeDepositStatus.stories.tsx +3 -3
- package/src/contract-functions/getBasculeDepositStatus/getBasculeDepositStatus.ts +6 -6
- package/src/contract-functions/getLBTCMintingFee/getLBTCMintingFee.tsx +16 -23
- package/src/contract-functions/getLBTCTotalSupply/getLBTCTotalSupply.stories.tsx +3 -4
- package/src/contract-functions/getLBTCTotalSupply/getLBTCTotalSupply.ts +8 -4
- package/src/contract-functions/getPermitNonce/getPermitNonce.stories.tsx +2 -2
- package/src/contract-functions/getPermitNonce/getPermitNonce.ts +8 -4
- package/src/contract-functions/getShareValue/getShareValue.stories.tsx +2 -2
- package/src/contract-functions/getShareValue/getShareValue.ts +4 -4
- package/src/contract-functions/getSharesByAddress/getSharesByAddress.stories.tsx +5 -5
- package/src/contract-functions/getSharesByAddress/getSharesByAddress.ts +4 -4
- package/src/contract-functions/getStakeAndBakeFee/getStakeAndBakeFee.stories.tsx +6 -6
- package/src/contract-functions/getStakeAndBakeFee/getStakeAndBakeFee.tsx +7 -7
- package/src/contract-functions/signLbtcDestionationAddr/signLbtcDestinationAddr.ts +1 -1
- package/src/contract-functions/signLbtcDestionationAddr/signLbtcDestionationAddr.stories.tsx +5 -5
- package/src/contract-functions/signNetworkFee/signNetworkFee.stories.tsx +7 -7
- package/src/contract-functions/signNetworkFee/signNetworkFee.ts +4 -4
- package/src/contract-functions/signStakeAndBake/signStakeAndBake.stories.tsx +6 -6
- package/src/contract-functions/signStakeAndBake/signStakeAndBake.ts +7 -7
- package/src/contract-functions/unstakeLBTC/unstakeLBTC.stories.tsx +8 -8
- package/src/contract-functions/unstakeLBTC/unstakeLBTC.ts +10 -10
- package/src/metrics/get-lbtc-stats.stories.tsx +1 -1
- package/src/metrics/get-lbtc-stats.ts +4 -3
- package/src/metrics/get-rewards-info.ts +22 -2
- package/src/rewards/lib/claim-reward.stories.tsx +9 -9
- package/src/rewards/lib/claim-reward.ts +6 -6
- package/src/rewards/lib/get-reward-balances.stories.tsx +4 -4
- package/src/rewards/lib/get-reward-balances.ts +4 -4
- package/src/rewards/lib/get-reward-signing-data.stories.tsx +4 -4
- package/src/rewards/lib/get-reward-signing-data.ts +3 -3
- package/src/rewards/lib/get-reward-withdrawal-fee.stories.tsx +4 -4
- package/src/rewards/lib/get-reward-withdrawal-fee.ts +3 -3
- package/src/rewards/lib/get-reward-withdrawals.stories.tsx +4 -4
- package/src/rewards/lib/get-reward-withdrawals.ts +3 -3
- package/src/stories/components/decorators/wagmi-decorator.tsx +1 -1
- package/src/stories/hooks/useConnection.ts +2 -2
- package/src/tokens/abi/ASSET_ROUTER_ABI.ts +37 -8
- package/src/tokens/lbtc-addresses.ts +2 -2
- package/src/tokens/token-addresses.ts +0 -8
- package/src/tokens/tokens.ts +74 -36
- package/src/utils/env.ts +1 -1
- package/src/vaults/lib/config.ts +4 -4
- package/src/vaults/lib/metrics/get-vault-apy.stories.tsx +3 -3
- package/src/vaults/lib/metrics/get-vault-apy.ts +2 -2
- package/src/vaults/lib/metrics/get-vault-points.stories.tsx +3 -3
- package/src/vaults/lib/metrics/get-vault-points.ts +2 -2
- package/src/vaults/lib/metrics/get-vault-tvl.stories.tsx +3 -3
- package/src/vaults/lib/metrics/get-vault-tvl.ts +8 -8
- package/src/vaults/lib/ops/cancel-withdraw.stories.tsx +6 -6
- package/src/vaults/lib/ops/deposit.stories.tsx +7 -7
- package/src/vaults/lib/ops/deposit.ts +5 -5
- package/src/vaults/lib/ops/get-vault-deposits.stories.tsx +5 -5
- package/src/vaults/lib/ops/get-vault-deposits.ts +11 -11
- package/src/vaults/lib/ops/get-vault-withdrawals.stories.tsx +4 -4
- package/src/vaults/lib/ops/get-vault-withdrawals.ts +9 -9
- package/src/vaults/lib/ops/withdraw.stories.tsx +7 -7
- package/src/vaults/lib/ops/withdraw.ts +5 -5
|
@@ -1,22 +1,22 @@
|
|
|
1
|
+
import { Env } from '@lombard.finance/sdk-common';
|
|
1
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { ChainId } from '../../common/chains';
|
|
4
|
+
import { Button } from '../../stories/components/Button';
|
|
5
|
+
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
6
|
+
import { ConnectButton } from '../../stories/components/ConnectButton';
|
|
2
7
|
import {
|
|
3
8
|
functionType,
|
|
4
9
|
wagmiDecorator,
|
|
5
10
|
} from '../../stories/components/decorators';
|
|
6
|
-
import { Button } from '../../stories/components/Button';
|
|
7
|
-
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
8
11
|
import { ErrorBlock } from '../../stories/components/error-block';
|
|
9
|
-
import
|
|
10
|
-
import { RewardToken } from './reward-tokens';
|
|
11
|
-
import { Env } from '@lombard.finance/sdk-common';
|
|
12
|
-
import { claimReward, ClaimRewardParameters } from './claim-reward';
|
|
13
|
-
import { ConnectButton } from '../../stories/components/ConnectButton';
|
|
12
|
+
import { EXAMPLE_BABYLON_ADDRESS } from '../../stories/constants';
|
|
14
13
|
import {
|
|
15
14
|
canPerformAction,
|
|
16
15
|
useConnection,
|
|
17
16
|
} from '../../stories/hooks/useConnection';
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
17
|
+
import useQuery from '../../stories/hooks/useQuery';
|
|
18
|
+
import { ClaimRewardParameters, claimReward } from './claim-reward';
|
|
19
|
+
import { RewardToken } from './reward-tokens';
|
|
20
20
|
|
|
21
21
|
const meta = {
|
|
22
22
|
title: 'rewards/claimReward',
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { CommonWriteParameters } from '../../common/parameters';
|
|
3
1
|
import axios from 'axios';
|
|
4
|
-
import
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
5
3
|
import { makeWalletClient } from '../../clients/wallet-client';
|
|
6
|
-
import {
|
|
4
|
+
import { getApiConfig } from '../../common/api-config';
|
|
5
|
+
import { CommonWriteParameters } from '../../common/parameters';
|
|
7
6
|
import { getRewardSigningData } from './get-reward-signing-data';
|
|
7
|
+
import { getRewardWithdrawalFee } from './get-reward-withdrawal-fee';
|
|
8
8
|
import {
|
|
9
|
-
mapDataToRewardWithdrawal,
|
|
10
9
|
WithdrawalData,
|
|
10
|
+
mapDataToRewardWithdrawal,
|
|
11
11
|
} from './get-reward-withdrawals';
|
|
12
|
-
import {
|
|
12
|
+
import { RewardToken, isRewardTokenSupported } from './reward-tokens';
|
|
13
13
|
|
|
14
14
|
type Response = {
|
|
15
15
|
withdrawal: WithdrawalData;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
import { Env } from '@lombard.finance/sdk-common';
|
|
1
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { Button } from '../../stories/components/Button';
|
|
4
|
+
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
2
5
|
import {
|
|
3
6
|
functionType,
|
|
4
7
|
wagmiDecorator,
|
|
5
8
|
} from '../../stories/components/decorators';
|
|
6
|
-
import { Button } from '../../stories/components/Button';
|
|
7
|
-
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
8
9
|
import { ErrorBlock } from '../../stories/components/error-block';
|
|
9
10
|
import { EXAMPLE_EVM_ADDRESS } from '../../stories/constants';
|
|
10
11
|
import useQuery from '../../stories/hooks/useQuery';
|
|
11
12
|
import {
|
|
12
|
-
getRewardBalances,
|
|
13
13
|
GetRewardBalancesParameters,
|
|
14
|
+
getRewardBalances,
|
|
14
15
|
} from './get-reward-balances';
|
|
15
16
|
import { RewardToken } from './reward-tokens';
|
|
16
|
-
import { Env } from '@lombard.finance/sdk-common';
|
|
17
17
|
|
|
18
18
|
const meta = {
|
|
19
19
|
title: 'rewards/getRewardBalances',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Address } from 'viem';
|
|
2
|
-
import { IEnvParam } from '../../common/parameters';
|
|
3
|
-
import { getApiConfig } from '../../common/api-config';
|
|
4
1
|
import axios from 'axios';
|
|
5
|
-
import { isRewardTokenSupported, RewardToken } from './reward-tokens';
|
|
6
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { Address } from 'viem';
|
|
4
|
+
import { getApiConfig } from '../../common/api-config';
|
|
5
|
+
import { IEnvParam } from '../../common/parameters';
|
|
6
|
+
import { RewardToken, isRewardTokenSupported } from './reward-tokens';
|
|
7
7
|
|
|
8
8
|
export enum RewardBlockchainType {
|
|
9
9
|
Undefined = 'BLOCKCHAIN_TYPE_UNDEFINED',
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import { Env } from '@lombard.finance/sdk-common';
|
|
1
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { Button } from '../../stories/components/Button';
|
|
4
|
+
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
2
5
|
import {
|
|
3
6
|
functionType,
|
|
4
7
|
wagmiDecorator,
|
|
5
8
|
} from '../../stories/components/decorators';
|
|
6
|
-
import { Button } from '../../stories/components/Button';
|
|
7
|
-
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
8
9
|
import { ErrorBlock } from '../../stories/components/error-block';
|
|
9
10
|
import {
|
|
10
11
|
EXAMPLE_BABYLON_ADDRESS,
|
|
11
12
|
EXAMPLE_EVM_ADDRESS,
|
|
12
13
|
} from '../../stories/constants';
|
|
13
14
|
import useQuery from '../../stories/hooks/useQuery';
|
|
14
|
-
import { RewardToken } from './reward-tokens';
|
|
15
|
-
import { Env } from '@lombard.finance/sdk-common';
|
|
16
15
|
import { getRewardSigningData } from './get-reward-signing-data';
|
|
17
16
|
import { getRewardWithdrawalFee } from './get-reward-withdrawal-fee';
|
|
17
|
+
import { RewardToken } from './reward-tokens';
|
|
18
18
|
|
|
19
19
|
const meta = {
|
|
20
20
|
title: 'rewards/getRewardSigningData',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { IEnvParam } from '../../common/parameters';
|
|
3
1
|
import axios from 'axios';
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
4
3
|
import { getApiConfig } from '../../common/api-config';
|
|
5
|
-
import {
|
|
4
|
+
import { IEnvParam } from '../../common/parameters';
|
|
5
|
+
import { RewardToken, isRewardTokenSupported } from './reward-tokens';
|
|
6
6
|
|
|
7
7
|
const SIGNING_DATA_URL =
|
|
8
8
|
'/api/v1/distribution/account/{from}/withdrawals/{to}/signing-data';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { Env } from '@lombard.finance/sdk-common';
|
|
1
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { Button } from '../../stories/components/Button';
|
|
4
|
+
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
2
5
|
import {
|
|
3
6
|
functionType,
|
|
4
7
|
wagmiDecorator,
|
|
5
8
|
} from '../../stories/components/decorators';
|
|
6
|
-
import { Button } from '../../stories/components/Button';
|
|
7
|
-
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
8
9
|
import { ErrorBlock } from '../../stories/components/error-block';
|
|
9
10
|
import { EXAMPLE_EVM_ADDRESS } from '../../stories/constants';
|
|
10
11
|
import useQuery from '../../stories/hooks/useQuery';
|
|
11
|
-
import { RewardToken } from './reward-tokens';
|
|
12
|
-
import { Env } from '@lombard.finance/sdk-common';
|
|
13
12
|
import { getRewardWithdrawalFee } from './get-reward-withdrawal-fee';
|
|
13
|
+
import { RewardToken } from './reward-tokens';
|
|
14
14
|
|
|
15
15
|
const meta = {
|
|
16
16
|
title: 'rewards/getRewardWithdrawalFee',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IEnvParam } from '../../common/parameters';
|
|
2
|
-
import { getApiConfig } from '../../common/api-config';
|
|
3
1
|
import axios from 'axios';
|
|
4
2
|
import BigNumber from 'bignumber.js';
|
|
5
|
-
import {
|
|
3
|
+
import { getApiConfig } from '../../common/api-config';
|
|
4
|
+
import { IEnvParam } from '../../common/parameters';
|
|
5
|
+
import { RewardToken, isRewardTokenSupported } from './reward-tokens';
|
|
6
6
|
|
|
7
7
|
const REWARDS_WITHDRAWAL_FEE_URL = '/api/v1/distribution/account/{address}/fee';
|
|
8
8
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { Env } from '@lombard.finance/sdk-common';
|
|
1
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { Button } from '../../stories/components/Button';
|
|
4
|
+
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
2
5
|
import {
|
|
3
6
|
functionType,
|
|
4
7
|
wagmiDecorator,
|
|
5
8
|
} from '../../stories/components/decorators';
|
|
6
|
-
import { Button } from '../../stories/components/Button';
|
|
7
|
-
import { CodeBlock } from '../../stories/components/CodeBlock';
|
|
8
9
|
import { ErrorBlock } from '../../stories/components/error-block';
|
|
9
10
|
import { EXAMPLE_EVM_ADDRESS } from '../../stories/constants';
|
|
10
11
|
import useQuery from '../../stories/hooks/useQuery';
|
|
11
|
-
import { RewardToken } from './reward-tokens';
|
|
12
|
-
import { Env } from '@lombard.finance/sdk-common';
|
|
13
12
|
import { getRewardWithdrawals } from './get-reward-withdrawals';
|
|
13
|
+
import { RewardToken } from './reward-tokens';
|
|
14
14
|
|
|
15
15
|
const meta = {
|
|
16
16
|
title: 'rewards/getRewardWithdrawals',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Address } from 'viem';
|
|
2
|
-
import { IEnvParam } from '../../common/parameters';
|
|
3
|
-
import { getApiConfig } from '../../common/api-config';
|
|
4
1
|
import axios from 'axios';
|
|
5
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { Address } from 'viem';
|
|
4
|
+
import { getApiConfig } from '../../common/api-config';
|
|
5
|
+
import { IEnvParam } from '../../common/parameters';
|
|
6
6
|
import { ensureHex } from '../../utils/hex';
|
|
7
7
|
import { RewardToken } from './reward-tokens';
|
|
8
8
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
2
|
-
import { rpcUrlConfig } from '../../../clients/rpc-url-config';
|
|
3
2
|
import { ReactNode } from 'react';
|
|
4
3
|
import {
|
|
5
4
|
base,
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
swellchain,
|
|
20
19
|
} from 'viem/chains';
|
|
21
20
|
import { createConfig, http, WagmiProvider } from 'wagmi';
|
|
21
|
+
import { rpcUrlConfig } from '../../../clients/rpc-url-config';
|
|
22
22
|
import { katana, katanaTatara, tac } from '../../../common/chains';
|
|
23
23
|
|
|
24
24
|
const config = createConfig({
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { EIP1193Provider } from 'viem';
|
|
1
3
|
import {
|
|
2
4
|
Config,
|
|
3
5
|
useAccount,
|
|
@@ -6,8 +8,6 @@ import {
|
|
|
6
8
|
useDisconnect as useWagmiDisconnect,
|
|
7
9
|
} from 'wagmi';
|
|
8
10
|
import { injected } from 'wagmi/connectors';
|
|
9
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
10
|
-
import { EIP1193Provider } from 'viem';
|
|
11
11
|
import { ChainId } from '../../common/chains';
|
|
12
12
|
|
|
13
13
|
type CanPerformAction = {
|
|
@@ -682,7 +682,10 @@ export default [
|
|
|
682
682
|
type: 'function',
|
|
683
683
|
},
|
|
684
684
|
{
|
|
685
|
-
inputs: [
|
|
685
|
+
inputs: [
|
|
686
|
+
{ internalType: 'address', name: 'token', type: 'address' },
|
|
687
|
+
{ internalType: 'address', name: 'newVal', type: 'address' },
|
|
688
|
+
],
|
|
686
689
|
name: 'changeOracle',
|
|
687
690
|
outputs: [],
|
|
688
691
|
stateMutability: 'nonpayable',
|
|
@@ -723,7 +726,10 @@ export default [
|
|
|
723
726
|
type: 'function',
|
|
724
727
|
},
|
|
725
728
|
{
|
|
726
|
-
inputs: [
|
|
729
|
+
inputs: [
|
|
730
|
+
{ internalType: 'address', name: 'token', type: 'address' },
|
|
731
|
+
{ internalType: 'uint64', name: 'newValue', type: 'uint64' },
|
|
732
|
+
],
|
|
727
733
|
name: 'changeToNativeCommission',
|
|
728
734
|
outputs: [],
|
|
729
735
|
stateMutability: 'nonpayable',
|
|
@@ -745,6 +751,28 @@ export default [
|
|
|
745
751
|
stateMutability: 'nonpayable',
|
|
746
752
|
type: 'function',
|
|
747
753
|
},
|
|
754
|
+
{
|
|
755
|
+
inputs: [
|
|
756
|
+
{ internalType: 'address', name: 'token', type: 'address' },
|
|
757
|
+
{ internalType: 'uint256', name: 'redeemFee', type: 'uint256' },
|
|
758
|
+
{
|
|
759
|
+
internalType: 'uint256',
|
|
760
|
+
name: 'redeemForBtcMinAmount',
|
|
761
|
+
type: 'uint256',
|
|
762
|
+
},
|
|
763
|
+
{ internalType: 'address', name: 'oracle_', type: 'address' },
|
|
764
|
+
{
|
|
765
|
+
internalType: 'uint256',
|
|
766
|
+
name: 'maximumMintCommission_',
|
|
767
|
+
type: 'uint256',
|
|
768
|
+
},
|
|
769
|
+
{ internalType: 'uint64', name: 'toNativeCommission_', type: 'uint64' },
|
|
770
|
+
],
|
|
771
|
+
name: 'changeTokenConfigExt',
|
|
772
|
+
outputs: [],
|
|
773
|
+
stateMutability: 'nonpayable',
|
|
774
|
+
type: 'function',
|
|
775
|
+
},
|
|
748
776
|
{
|
|
749
777
|
inputs: [],
|
|
750
778
|
name: 'defaultAdmin',
|
|
@@ -870,9 +898,7 @@ export default [
|
|
|
870
898
|
{ internalType: 'bytes32', name: 'ledgerChainId_', type: 'bytes32' },
|
|
871
899
|
{ internalType: 'bytes32', name: 'bitcoinChainId_', type: 'bytes32' },
|
|
872
900
|
{ internalType: 'address', name: 'mailbox_', type: 'address' },
|
|
873
|
-
{ internalType: 'address', name: 'oracle_', type: 'address' },
|
|
874
901
|
{ internalType: 'address', name: 'bascule_', type: 'address' },
|
|
875
|
-
{ internalType: 'uint64', name: 'toNativeCommission_', type: 'uint64' },
|
|
876
902
|
],
|
|
877
903
|
name: 'initialize',
|
|
878
904
|
outputs: [],
|
|
@@ -887,7 +913,7 @@ export default [
|
|
|
887
913
|
type: 'function',
|
|
888
914
|
},
|
|
889
915
|
{
|
|
890
|
-
inputs: [],
|
|
916
|
+
inputs: [{ internalType: 'address', name: 'token', type: 'address' }],
|
|
891
917
|
name: 'maxMintCommission',
|
|
892
918
|
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
893
919
|
stateMutability: 'view',
|
|
@@ -923,7 +949,7 @@ export default [
|
|
|
923
949
|
type: 'function',
|
|
924
950
|
},
|
|
925
951
|
{
|
|
926
|
-
inputs: [],
|
|
952
|
+
inputs: [{ internalType: 'address', name: 'token', type: 'address' }],
|
|
927
953
|
name: 'oracle',
|
|
928
954
|
outputs: [{ internalType: 'contract IOracle', name: '', type: 'address' }],
|
|
929
955
|
stateMutability: 'view',
|
|
@@ -1040,7 +1066,10 @@ export default [
|
|
|
1040
1066
|
type: 'function',
|
|
1041
1067
|
},
|
|
1042
1068
|
{
|
|
1043
|
-
inputs: [
|
|
1069
|
+
inputs: [
|
|
1070
|
+
{ internalType: 'address', name: 'token', type: 'address' },
|
|
1071
|
+
{ internalType: 'uint256', name: 'fee', type: 'uint256' },
|
|
1072
|
+
],
|
|
1044
1073
|
name: 'setMaxMintCommission',
|
|
1045
1074
|
outputs: [],
|
|
1046
1075
|
stateMutability: 'nonpayable',
|
|
@@ -1071,7 +1100,7 @@ export default [
|
|
|
1071
1100
|
type: 'function',
|
|
1072
1101
|
},
|
|
1073
1102
|
{
|
|
1074
|
-
inputs: [],
|
|
1103
|
+
inputs: [{ internalType: 'address', name: 'token', type: 'address' }],
|
|
1075
1104
|
name: 'toNativeCommission',
|
|
1076
1105
|
outputs: [{ internalType: 'uint64', name: '', type: 'uint64' }],
|
|
1077
1106
|
stateMutability: 'view',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { DEFAULT_ENV, Env } from '@lombard.finance/sdk-common';
|
|
1
2
|
import { Address } from 'viem';
|
|
2
3
|
import { ChainId } from '../common/chains';
|
|
3
|
-
import {
|
|
4
|
-
import { Token, TOKEN_ADDRESSES } from './token-addresses';
|
|
4
|
+
import { TOKEN_ADDRESSES, Token } from './token-addresses';
|
|
5
5
|
|
|
6
6
|
type LbtcContractAddresses = Partial<Record<ChainId, Address>>;
|
|
7
7
|
|
|
@@ -129,11 +129,3 @@ export const TOKEN_ADDRESSES: TokenAddresses = {
|
|
|
129
129
|
},
|
|
130
130
|
},
|
|
131
131
|
};
|
|
132
|
-
|
|
133
|
-
// TODO: Add additional chains and envs once new LBTC contract is deployed
|
|
134
|
-
// on them, remove this logic when all chains are updated.
|
|
135
|
-
export const STLBTC_CHAINS: ChainId[] = [
|
|
136
|
-
ChainId.sepolia,
|
|
137
|
-
ChainId.binanceSmartChainTestnet,
|
|
138
|
-
];
|
|
139
|
-
export const STLBTC_ENVS: Env[] = [Env.dev];
|
package/src/tokens/tokens.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { DEFAULT_ENV, Env } from '@lombard.finance/sdk-common';
|
|
2
|
-
import { ChainId } from '../common/chains';
|
|
3
|
-
import { makePublicClient } from '../clients/public-client';
|
|
4
2
|
import BigNumber from 'bignumber.js';
|
|
5
|
-
import { type Abi, Address, erc20Abi, PublicClient } from 'viem';
|
|
6
|
-
import {
|
|
7
|
-
STLBTC_CHAINS,
|
|
8
|
-
STLBTC_ENVS,
|
|
9
|
-
TOKEN_ADDRESSES,
|
|
10
|
-
Token,
|
|
11
|
-
} from './token-addresses';
|
|
3
|
+
import { type Abi, Address, erc20Abi, PublicClient, zeroAddress } from 'viem';
|
|
4
|
+
import { TOKEN_ADDRESSES, Token } from './token-addresses';
|
|
12
5
|
import { LBTC_ABI } from './abi/LBTC_ABI';
|
|
13
6
|
import { TokenContractAddressNotFoundError } from '../utils/err';
|
|
14
7
|
import BTCK_ABI from './abi/BTCK_ABI';
|
|
15
8
|
import STLBTC_ABI from './abi/STLBTC_ABI';
|
|
16
9
|
import NATIVE_LBTC_ABI from './abi/NATIVE_LBTC_ABI';
|
|
10
|
+
import { ChainId } from '../common/chains';
|
|
11
|
+
import { makePublicClient } from '../clients/public-client';
|
|
17
12
|
|
|
18
13
|
export type TokenInfo = {
|
|
19
14
|
address: Address;
|
|
@@ -22,55 +17,98 @@ export type TokenInfo = {
|
|
|
22
17
|
decimals: number;
|
|
23
18
|
};
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
:
|
|
20
|
+
const MAYBE_UPGRADED_CONTRACT_ABI = [
|
|
21
|
+
{
|
|
22
|
+
inputs: [],
|
|
23
|
+
name: 'getAssetRouter',
|
|
24
|
+
outputs: [{ internalType: 'address', name: '', type: 'address' }],
|
|
25
|
+
stateMutability: 'view',
|
|
26
|
+
type: 'function',
|
|
27
|
+
},
|
|
28
|
+
] as const;
|
|
29
|
+
const UPGRADED_CONTRACT_POINTER = MAYBE_UPGRADED_CONTRACT_ABI[0].name;
|
|
30
|
+
|
|
31
|
+
export async function isUpgradedContract(
|
|
32
|
+
token: Token.LBTC | Token.BTCK,
|
|
33
|
+
chainId: ChainId,
|
|
34
|
+
env?: Env,
|
|
35
|
+
rpcUrl?: string,
|
|
36
|
+
) {
|
|
37
|
+
const environment = env || DEFAULT_ENV;
|
|
38
|
+
const address = TOKEN_ADDRESSES[token]?.[environment]?.[chainId];
|
|
39
|
+
if (!address) {
|
|
40
|
+
throw new TokenContractAddressNotFoundError(token, chainId, environment);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const publicClient = makePublicClient({ chainId, rpcUrl, env: environment });
|
|
44
|
+
try {
|
|
45
|
+
const assetRouter = await publicClient.readContract({
|
|
46
|
+
abi: MAYBE_UPGRADED_CONTRACT_ABI,
|
|
47
|
+
address,
|
|
48
|
+
functionName: UPGRADED_CONTRACT_POINTER,
|
|
49
|
+
});
|
|
50
|
+
return assetRouter !== zeroAddress;
|
|
51
|
+
} catch (_err) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type AbiForLBTC =
|
|
57
|
+
| typeof STLBTC_ABI // upgraded
|
|
58
|
+
| typeof LBTC_ABI; // legacy
|
|
59
|
+
|
|
60
|
+
type AbiForBTCK =
|
|
61
|
+
| typeof NATIVE_LBTC_ABI // upgraded
|
|
62
|
+
| typeof BTCK_ABI; // legacy
|
|
63
|
+
|
|
64
|
+
type AbiForNativeLBTC = typeof NATIVE_LBTC_ABI;
|
|
65
|
+
|
|
66
|
+
type AbiFor<TToken extends Token> = TToken extends Token.LBTC
|
|
67
|
+
? AbiForLBTC
|
|
32
68
|
: TToken extends Token.BTCK
|
|
33
|
-
?
|
|
69
|
+
? AbiForBTCK
|
|
34
70
|
: TToken extends Token.NativeLBTC
|
|
35
|
-
?
|
|
71
|
+
? AbiForNativeLBTC
|
|
36
72
|
: typeof erc20Abi;
|
|
37
73
|
|
|
38
|
-
type TokenContractInfo<TToken extends Token
|
|
39
|
-
abi: AbiFor<TToken
|
|
74
|
+
type TokenContractInfo<TToken extends Token> = {
|
|
75
|
+
abi: AbiFor<TToken>;
|
|
40
76
|
address: Address;
|
|
41
|
-
chainId:
|
|
77
|
+
chainId: ChainId;
|
|
42
78
|
};
|
|
43
79
|
|
|
44
|
-
export const
|
|
80
|
+
export const isUpgradedAbi = (
|
|
81
|
+
abi: Abi,
|
|
82
|
+
): abi is typeof STLBTC_ABI | typeof NATIVE_LBTC_ABI => {
|
|
45
83
|
const redeemForBtcAbi = abi.find(
|
|
46
|
-
a => a.type === 'function' && a.name ===
|
|
84
|
+
a => a.type === 'function' && a.name === UPGRADED_CONTRACT_POINTER,
|
|
47
85
|
);
|
|
48
86
|
return redeemForBtcAbi != null;
|
|
49
87
|
};
|
|
50
88
|
|
|
51
|
-
export function getTokenContractInfo<
|
|
52
|
-
TToken extends Token,
|
|
53
|
-
TChainId extends ChainId,
|
|
54
|
-
>(
|
|
89
|
+
export async function getTokenContractInfo<TToken extends Token>(
|
|
55
90
|
token: TToken,
|
|
56
|
-
chainId:
|
|
91
|
+
chainId: ChainId,
|
|
57
92
|
env?: Env,
|
|
58
|
-
): TokenContractInfo<TToken
|
|
93
|
+
): Promise<TokenContractInfo<TToken>> {
|
|
59
94
|
const environment = env || DEFAULT_ENV;
|
|
60
95
|
|
|
61
|
-
let abi: AbiFor<TToken
|
|
96
|
+
let abi: AbiFor<TToken> | undefined = undefined;
|
|
62
97
|
if (token === Token.LBTC) {
|
|
63
|
-
if (
|
|
64
|
-
abi = STLBTC_ABI as AbiFor<TToken
|
|
98
|
+
if (await isUpgradedContract(Token.LBTC, chainId, environment)) {
|
|
99
|
+
abi = STLBTC_ABI as AbiFor<TToken>;
|
|
65
100
|
} else {
|
|
66
|
-
abi = LBTC_ABI as AbiFor<TToken
|
|
101
|
+
abi = LBTC_ABI as AbiFor<TToken>;
|
|
67
102
|
}
|
|
68
103
|
} else if (token === Token.BTCK) {
|
|
69
|
-
abi = BTCK_ABI as AbiFor<TToken
|
|
104
|
+
abi = BTCK_ABI as AbiFor<TToken>;
|
|
105
|
+
if (await isUpgradedContract(Token.BTCK, chainId, environment)) {
|
|
106
|
+
abi = NATIVE_LBTC_ABI as AbiFor<TToken>;
|
|
107
|
+
}
|
|
70
108
|
} else if (token === Token.NativeLBTC) {
|
|
71
109
|
abi = NATIVE_LBTC_ABI as AbiFor<TToken>;
|
|
72
110
|
} else {
|
|
73
|
-
abi = erc20Abi as AbiFor<TToken
|
|
111
|
+
abi = erc20Abi as AbiFor<TToken>;
|
|
74
112
|
}
|
|
75
113
|
|
|
76
114
|
const address = TOKEN_ADDRESSES[token]?.[environment]?.[chainId];
|
|
@@ -121,7 +159,7 @@ export async function getTokenInfo(
|
|
|
121
159
|
env?: Env,
|
|
122
160
|
rpcUrl?: string,
|
|
123
161
|
): Promise<TokenInfo | undefined> {
|
|
124
|
-
const tokenContractInfo = getTokenContractInfo(token, chainId, env);
|
|
162
|
+
const tokenContractInfo = await getTokenContractInfo(token, chainId, env);
|
|
125
163
|
if (!tokenContractInfo) return;
|
|
126
164
|
|
|
127
165
|
const publicClient = makePublicClient({ chainId, rpcUrl });
|
package/src/utils/env.ts
CHANGED
package/src/vaults/lib/config.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { Abi, Address } from 'viem';
|
|
1
2
|
import { ChainId } from '../../common/chains';
|
|
3
|
+
import { Token } from '../../tokens/token-addresses';
|
|
2
4
|
import VEDA_VAULT_ABI from '../abi/VEDA_VAULT_ABI.json';
|
|
3
5
|
import VEDA_VAULT_ACCOUNTANT_ABI from '../abi/VEDA_VAULT_ACCOUNTANT_ABI.json';
|
|
4
|
-
import VEDA_VAULT_LENS_ABI from '../abi/VEDA_VAULT_LENS_ABI.json';
|
|
5
6
|
import VEDA_VAULT_BASE_ASSET_ABI from '../abi/VEDA_VAULT_BASE_ASSET_ABI.json';
|
|
7
|
+
import VEDA_VAULT_BORING_WITHDRAW_QUEUE_ABI from '../abi/VEDA_VAULT_BORING_WITHDRAW_QUEUE_ABI.json';
|
|
8
|
+
import VEDA_VAULT_LENS_ABI from '../abi/VEDA_VAULT_LENS_ABI.json';
|
|
6
9
|
import VEDA_VAULT_SPENDER_ABI from '../abi/VEDA_VAULT_SPENDER_ABI.json';
|
|
7
10
|
import VEDA_VAULT_TELLER_ABI from '../abi/VEDA_VAULT_TELLER_ABI.json';
|
|
8
|
-
import VEDA_VAULT_BORING_WITHDRAW_QUEUE_ABI from '../abi/VEDA_VAULT_BORING_WITHDRAW_QUEUE_ABI.json';
|
|
9
|
-
import { Abi, Address } from 'viem';
|
|
10
|
-
import { Token } from '../../tokens/token-addresses';
|
|
11
11
|
|
|
12
12
|
type ContractInfo = {
|
|
13
13
|
abi: Abi;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { Button } from '../../../stories/components/Button';
|
|
3
3
|
import { CodeBlock } from '../../../stories/components/CodeBlock';
|
|
4
|
-
import useQuery from '../../../stories/hooks/useQuery';
|
|
5
4
|
import {
|
|
6
5
|
functionType,
|
|
7
6
|
wagmiDecorator,
|
|
8
7
|
} from '../../../stories/components/decorators';
|
|
9
|
-
import { Vault } from '../config';
|
|
10
8
|
import { ErrorBlock } from '../../../stories/components/error-block';
|
|
11
|
-
import
|
|
9
|
+
import useQuery from '../../../stories/hooks/useQuery';
|
|
10
|
+
import { Vault } from '../config';
|
|
11
|
+
import { GetVaultApyParameters, getVaultApy } from './get-vault-apy';
|
|
12
12
|
|
|
13
13
|
const meta = {
|
|
14
14
|
title: 'vault/metrics/getVaultApy',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import { ChainId } from '../../../common/chains';
|
|
3
|
-
import { isVedaVaultChain, Vault, VAULTS, VedaVaultChain } from '../config';
|
|
4
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { ChainId } from '../../../common/chains';
|
|
5
4
|
import { orderBy } from '../../../utils/array';
|
|
5
|
+
import { VAULTS, Vault, VedaVaultChain, isVedaVaultChain } from '../config';
|
|
6
6
|
|
|
7
7
|
export type GetVaultApyParameters = {
|
|
8
8
|
aggregationPeriod?: 7 | 14 | 30;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { Button } from '../../../stories/components/Button';
|
|
3
3
|
import { CodeBlock } from '../../../stories/components/CodeBlock';
|
|
4
|
-
import useQuery from '../../../stories/hooks/useQuery';
|
|
5
4
|
import {
|
|
6
5
|
functionType,
|
|
7
6
|
wagmiDecorator,
|
|
8
7
|
} from '../../../stories/components/decorators';
|
|
9
|
-
import { Vault } from '../config';
|
|
10
8
|
import { ErrorBlock } from '../../../stories/components/error-block';
|
|
11
9
|
import { EXAMPLE_EVM_ADDRESS } from '../../../stories/constants';
|
|
12
|
-
import
|
|
10
|
+
import useQuery from '../../../stories/hooks/useQuery';
|
|
11
|
+
import { Vault } from '../config';
|
|
12
|
+
import { GetVaultPointsParameters, getVaultPoints } from './get-vault-points';
|
|
13
13
|
|
|
14
14
|
const meta = {
|
|
15
15
|
title: 'vault/metrics/getVaultPoints',
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { Button } from '../../../stories/components/Button';
|
|
3
3
|
import { CodeBlock } from '../../../stories/components/CodeBlock';
|
|
4
|
-
import useQuery from '../../../stories/hooks/useQuery';
|
|
5
4
|
import {
|
|
6
5
|
functionType,
|
|
7
6
|
wagmiDecorator,
|
|
8
7
|
} from '../../../stories/components/decorators';
|
|
9
|
-
import { Vault } from '../config';
|
|
10
8
|
import { ErrorBlock } from '../../../stories/components/error-block';
|
|
11
|
-
import
|
|
9
|
+
import useQuery from '../../../stories/hooks/useQuery';
|
|
10
|
+
import { Vault } from '../config';
|
|
11
|
+
import { GetVaultTVLParameters, getVaultTVL } from './get-vault-tvl';
|
|
12
12
|
|
|
13
13
|
const meta = {
|
|
14
14
|
title: 'vault/metrics/getVaultTVL',
|