@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.
- package/README.md +60 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +73 -62
- package/dist/index2.cjs +62 -52
- package/dist/index2.cjs.map +1 -1
- package/dist/index2.js +8361 -12041
- package/dist/index2.js.map +1 -1
- package/package.json +35 -33
- package/src/api-functions/generateDepositBtcAddress/generateDepositBtcAddress.ts +4 -4
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddress.stories.tsx +8 -0
- package/src/api-functions/getDepositBtcAddress/getDepositBtcAddress.ts +3 -3
- package/src/api-functions/getDepositsByAddress/getDepositsByAddress.ts +8 -7
- package/src/api-functions/getUnstakesByAddress/getUnstakesByAddress.ts +5 -5
- package/src/api-functions/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +8 -0
- package/src/bridge/abi/CCIP_BRIDGE_ADAPTER_ABI.json +704 -0
- package/src/bridge/abi/OFT_BRIDGE_ADAPTER_ABI.json +912 -0
- package/src/bridge/index.ts +11 -0
- package/src/bridge/lib/bridge.stories.tsx +89 -0
- package/src/bridge/lib/bridge.ts +101 -0
- package/src/bridge/lib/ccip-bridge.stories.tsx +90 -0
- package/src/bridge/lib/ccip-bridge.ts +163 -0
- package/src/bridge/lib/config.ts +338 -0
- package/src/bridge/lib/oft-bridge.stories.tsx +89 -0
- package/src/bridge/lib/oft-bridge.ts +211 -0
- package/src/common/api-config.ts +8 -2
- package/src/common/blockchain-identifier.ts +32 -5
- package/src/common/chains.ts +13 -1
- package/src/common/contract-info.ts +8 -0
- package/src/contract-functions/approveLBTC/approveLBTC.stories.tsx +1 -1
- package/src/contract-functions/approveLBTC/approveLBTC.ts +3 -2
- package/src/contract-functions/claimLBTC/claimLBTC.ts +3 -2
- package/src/contract-functions/getBasculeDepositStatus/getBasculeDepositStatus.ts +10 -4
- package/src/contract-functions/getLBTCMintingFee/getLBTCMintingFee.tsx +14 -11
- package/src/contract-functions/getLBTCTotalSupply/getLBTCTotalSupply.ts +13 -9
- package/src/contract-functions/getPermitNonce/getPermitNonce.ts +16 -10
- package/src/contract-functions/getShareValue/getShareValue.stories.tsx +1 -1
- package/src/contract-functions/getShareValue/getShareValue.ts +1 -1
- package/src/contract-functions/getSharesByAddress/getSharesByAddress.stories.tsx +1 -1
- package/src/contract-functions/getSharesByAddress/getSharesByAddress.ts +1 -1
- package/src/contract-functions/getStakeAndBakeFee/getStakeAndBakeFee.stories.tsx +14 -1
- package/src/contract-functions/getStakeAndBakeFee/getStakeAndBakeFee.tsx +5 -1
- package/src/contract-functions/signNetworkFee/signNetworkFee.ts +3 -2
- package/src/contract-functions/signStakeAndBake/signStakeAndBake.stories.tsx +2 -1
- package/src/contract-functions/signStakeAndBake/signStakeAndBake.ts +8 -3
- package/src/contract-functions/unstakeLBTC/unstakeLBTC.ts +3 -2
- package/src/index.ts +26 -28
- package/src/metrics/get-lbtc-stats.stories.tsx +51 -0
- package/src/metrics/get-lbtc-stats.ts +38 -0
- package/src/rewards/lib/claim-reward.stories.tsx +1 -0
- package/src/rewards/lib/claim-reward.ts +5 -0
- package/src/rewards/lib/get-reward-signing-data.stories.tsx +1 -0
- package/src/rewards/lib/get-reward-signing-data.ts +4 -0
- package/src/tokens/abi/LBTC_ABI.json +1760 -1760
- package/src/tokens/abi/LBTC_ABI.ts +1761 -0
- package/src/tokens/lbtc-addresses.ts +1 -0
- package/src/tokens/token-addresses.ts +32 -0
- package/src/tokens/tokens.ts +59 -50
- package/src/utils/numbers.ts +3 -0
- package/src/vaults/index.ts +35 -176
- package/src/vaults/lib/config.ts +196 -0
- package/src/vaults/lib/metrics/get-vault-apy.stories.tsx +57 -0
- package/src/vaults/lib/metrics/get-vault-apy.ts +132 -0
- package/src/vaults/lib/{get-vault-points.stories.tsx → metrics/get-vault-points.stories.tsx} +8 -8
- package/src/vaults/lib/{get-vault-points.ts → metrics/get-vault-points.ts} +1 -1
- package/src/vaults/lib/metrics/get-vault-tvl.stories.tsx +57 -0
- package/src/vaults/lib/metrics/get-vault-tvl.ts +119 -0
- package/src/vaults/lib/{cancel-withdraw.stories.tsx → ops/cancel-withdraw.stories.tsx} +9 -9
- package/src/vaults/lib/{deposit.stories.tsx → ops/deposit.stories.tsx} +9 -9
- package/src/vaults/lib/{deposit.ts → ops/deposit.ts} +10 -10
- package/src/vaults/lib/{get-vault-deposits.stories.tsx → ops/get-vault-deposits.stories.tsx} +9 -9
- package/src/vaults/lib/{get-vault-deposits.ts → ops/get-vault-deposits.ts} +5 -5
- package/src/vaults/lib/{get-vault-withdrawals.stories.tsx → ops/get-vault-withdrawals.stories.tsx} +9 -9
- package/src/vaults/lib/{get-vault-withdrawals.ts → ops/get-vault-withdrawals.ts} +5 -5
- package/src/vaults/lib/{withdraw.stories.tsx → ops/withdraw.stories.tsx} +9 -9
- package/src/vaults/lib/{withdraw.ts → ops/withdraw.ts} +12 -12
- package/src/tokens/lbtc-contract.ts +0 -89
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { ChainId } from '../common/chains';
|
|
2
|
-
import { makePublicClient } from '../clients/public-client';
|
|
3
|
-
import { EIP1193Provider, getContract } from 'viem';
|
|
4
|
-
import LBTC_ABI from './abi/LBTC_ABI.json';
|
|
5
|
-
import { DEFAULT_ENV, Env } from '@lombard.finance/sdk-common';
|
|
6
|
-
import { getLbtcContractAddresses } from './lbtc-addresses';
|
|
7
|
-
import { makeWalletClient } from '../clients/wallet-client';
|
|
8
|
-
|
|
9
|
-
type GetLBTCContractParameters = {
|
|
10
|
-
/** The chain id on which LBTC contract is deployed. */
|
|
11
|
-
chainId: ChainId;
|
|
12
|
-
/** Optional RPC URL to connect to the blockchain. If not provided, a default RPC URL might be used. */
|
|
13
|
-
rpcUrl?: string;
|
|
14
|
-
/** The environment (optional). If not provided, it defaults to `prod`. */
|
|
15
|
-
env?: Env;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Gets the LBTC contract by the provided parameters.
|
|
20
|
-
*
|
|
21
|
-
* @throws {Error} - Throws an error if the contract address could not be determined.
|
|
22
|
-
*/
|
|
23
|
-
export function getLBTCContract({
|
|
24
|
-
chainId,
|
|
25
|
-
rpcUrl,
|
|
26
|
-
env = DEFAULT_ENV,
|
|
27
|
-
}: GetLBTCContractParameters) {
|
|
28
|
-
const addresses = getLbtcContractAddresses(env);
|
|
29
|
-
|
|
30
|
-
const contractAddress = addresses[chainId];
|
|
31
|
-
if (!contractAddress) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
`Could not determine the LBTC contract address for given chain id: ${chainId} (env: ${env})`,
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const client = makePublicClient({ chainId, rpcUrl });
|
|
38
|
-
|
|
39
|
-
const lbtcContract = getContract({
|
|
40
|
-
abi: LBTC_ABI,
|
|
41
|
-
address: contractAddress,
|
|
42
|
-
client,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return lbtcContract;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type GetWriteableLBTCContractParameters = {
|
|
49
|
-
/**
|
|
50
|
-
* The provider (required). An instance of the `EIP1193Provider` which adheres to the EIP-1193 standard for communication with Ethereum-compatible providers.
|
|
51
|
-
* @type {EIP1193Provider}
|
|
52
|
-
*/
|
|
53
|
-
provider: EIP1193Provider;
|
|
54
|
-
} & Pick<GetLBTCContractParameters, 'chainId' | 'env'>;
|
|
55
|
-
export function getWriteableLBTCContract({
|
|
56
|
-
chainId,
|
|
57
|
-
provider,
|
|
58
|
-
env = DEFAULT_ENV,
|
|
59
|
-
}: GetWriteableLBTCContractParameters) {
|
|
60
|
-
const addresses = getLbtcContractAddresses(env);
|
|
61
|
-
|
|
62
|
-
const contractAddress = addresses[chainId];
|
|
63
|
-
if (!contractAddress) {
|
|
64
|
-
throw new Error(
|
|
65
|
-
`Could not determine the LBTC contract address for given chain id: ${chainId} (env: ${env})`,
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const client = makeWalletClient({ provider, chainId });
|
|
70
|
-
|
|
71
|
-
const lbtcContract = getContract({
|
|
72
|
-
abi: LBTC_ABI,
|
|
73
|
-
address: contractAddress,
|
|
74
|
-
client,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
return lbtcContract;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function getLBTCContractInfo(chainId: ChainId, env?: Env) {
|
|
81
|
-
const addresses = getLbtcContractAddresses(env);
|
|
82
|
-
const contractAddress = addresses[chainId];
|
|
83
|
-
if (!contractAddress) {
|
|
84
|
-
throw new Error(
|
|
85
|
-
`Could not determine the LBTC contract address for given chain id: ${chainId} (env: ${env})`,
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
return { abi: LBTC_ABI, address: contractAddress };
|
|
89
|
-
}
|