@lombard.finance/sdk 3.6.8 → 3.6.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lombard.finance/sdk",
3
- "version": "3.6.8",
3
+ "version": "3.6.9",
4
4
  "dependencies": {
5
5
  "@lombard.finance/sdk-common": "^3.0.0",
6
6
  "viem": "^2.23.15",
@@ -39,10 +39,7 @@
39
39
  "./clients/*": "./src/clients/*.ts",
40
40
  "./utils/*": "./src/utils/*.ts"
41
41
  },
42
- "files": [
43
- "dist",
44
- "src"
45
- ],
42
+ "files": ["dist", "src"],
46
43
  "license": "MIT",
47
44
  "peerDependencies": {
48
45
  "@layerzerolabs/lz-v2-utilities": "3.0.17",
@@ -62,4 +59,4 @@
62
59
  },
63
60
  "type": "module",
64
61
  "types": "./src/index.ts"
65
- }
62
+ }
@@ -6,12 +6,18 @@ import {
6
6
  } from '../../common/blockchain-identifier';
7
7
  import {
8
8
  ChainId,
9
+ isSolanaChain,
10
+ isSuiChain,
9
11
  isValidChain,
10
12
  SolanaChain,
11
13
  SuiChain,
12
14
  } from '../../common/chains';
13
15
  import { IEnvParam } from '../../common/parameters';
14
- import { Token } from '../../tokens/token-addresses';
16
+ import {
17
+ getSolanaTokenAddress,
18
+ getSuiTokenAddress,
19
+ Token,
20
+ } from '../../tokens/token-addresses';
15
21
  import { getTokenContractInfo } from '../../tokens/tokens';
16
22
 
17
23
  export interface IDepositAddress {
@@ -198,13 +204,31 @@ export async function getDepositBtcAddress({
198
204
  aux_version: token === Token.BTCK ? 1 : undefined,
199
205
  };
200
206
  }
207
+
208
+ if (isSuiChain(chainId)) {
209
+ const tokenAddress = getSuiTokenAddress(chainId, env);
210
+ if (tokenAddress) {
211
+ tokenAddressFilter = {
212
+ token_address: tokenAddress.toLowerCase(),
213
+ };
214
+ }
215
+ }
216
+
217
+ if (isSolanaChain(chainId)) {
218
+ const tokenAddress = getSolanaTokenAddress(chainId, env);
219
+ if (tokenAddress) {
220
+ tokenAddressFilter = {
221
+ token_address: tokenAddress.toLowerCase(),
222
+ };
223
+ }
224
+ }
201
225
  } catch {
202
226
  // NOOP
203
227
  }
204
228
 
205
229
  const addresses = (_addresses || []).filter(a => {
206
230
  if (!tokenAddressFilter) {
207
- // Get only the non token specific deposit addresses.
231
+ // Get only the non token specific deposit addresses (legacy)
208
232
  return !a.deposit_metadata.token_address;
209
233
  }
210
234
 
@@ -104,6 +104,17 @@ export type SuiChain =
104
104
  | typeof SUI_LOCALNET_CHAIN
105
105
  | typeof SUI_MAINNET_CHAIN;
106
106
 
107
+ export const isSuiChain = (chainId: unknown): chainId is SuiChain => {
108
+ return (
109
+ [
110
+ SUI_DEVNET_CHAIN,
111
+ SUI_TESTNET_CHAIN,
112
+ SUI_LOCALNET_CHAIN,
113
+ SUI_MAINNET_CHAIN,
114
+ ] as string[]
115
+ ).includes(chainId as string);
116
+ };
117
+
107
118
  export const SOLANA_MAINNET_CHAIN = 'solana:mainnet-beta' as const;
108
119
  export const SOLANA_TESTNET_CHAIN = 'solana:testnet' as const;
109
120
  export const SOLANA_DEVNET_CHAIN = 'solana:devnet' as const;
@@ -113,6 +124,16 @@ export type SolanaChain =
113
124
  | typeof SOLANA_TESTNET_CHAIN
114
125
  | typeof SOLANA_DEVNET_CHAIN;
115
126
 
127
+ export const isSolanaChain = (chainId: unknown): chainId is SolanaChain => {
128
+ return (
129
+ [
130
+ SOLANA_MAINNET_CHAIN,
131
+ SOLANA_TESTNET_CHAIN,
132
+ SOLANA_DEVNET_CHAIN,
133
+ ] as string[]
134
+ ).includes(chainId as string);
135
+ };
136
+
116
137
  export const ChainId = {
117
138
  ethereum: 1,
118
139
  base: 8453,
@@ -1,6 +1,15 @@
1
- import { Env } from '@lombard.finance/sdk-common';
1
+ import { DEFAULT_ENV, Env } from '@lombard.finance/sdk-common';
2
2
  import { Address } from 'viem';
3
- import { ChainId } from '../common/chains';
3
+ import {
4
+ ChainId,
5
+ SOLANA_DEVNET_CHAIN,
6
+ SOLANA_MAINNET_CHAIN,
7
+ SOLANA_TESTNET_CHAIN,
8
+ SolanaChain,
9
+ SUI_MAINNET_CHAIN,
10
+ SUI_TESTNET_CHAIN,
11
+ SuiChain,
12
+ } from '../common/chains';
4
13
 
5
14
  export enum Token {
6
15
  // Lombard tokens:
@@ -24,14 +33,26 @@ export const RATIO_TOKEN_MAP: Record<RatioToken, Token> = {
24
33
  TOKEN_SYMBOL_STLBTC: Token.LBTC,
25
34
  };
26
35
 
27
- type TokenAddresses = Partial<
36
+ type TokenAddresses<
37
+ chain extends string | number | symbol = ChainId | SuiChain | SolanaChain,
38
+ > = Partial<
28
39
  Record<
29
40
  Token,
30
- Partial<Record<Env, Partial<Record<ChainId, Address | undefined>>>>
41
+ Partial<
42
+ Record<
43
+ Env,
44
+ Partial<
45
+ Record<
46
+ chain,
47
+ (chain extends ChainId | SuiChain ? Address : string) | undefined
48
+ >
49
+ >
50
+ >
51
+ >
31
52
  >
32
53
  >;
33
54
 
34
- export const TOKEN_ADDRESSES: TokenAddresses = {
55
+ export const TOKEN_ADDRESSES: TokenAddresses<ChainId> = {
35
56
  [Token.LBTC]: {
36
57
  [Env.prod]: {
37
58
  [ChainId.ethereum]: '0x8236a87084f8b84306f72007f36f2618a5634494',
@@ -130,3 +151,48 @@ export const TOKEN_ADDRESSES: TokenAddresses = {
130
151
  },
131
152
  },
132
153
  };
154
+
155
+ export const SUI_TOKEN_ADDRESSES: TokenAddresses<SuiChain> = {
156
+ [Token.LBTC]: {
157
+ [Env.prod]: {
158
+ [SUI_MAINNET_CHAIN]:
159
+ '0x3e8e9423d80e1774a7ca128fccd8bf5f1f7753be658c5e645929037f7c819040',
160
+ },
161
+ [Env.stage]: {
162
+ [SUI_TESTNET_CHAIN]:
163
+ '0x2d66430a27565b912f21be970e5ae1e8c0359f0b518c3235b751c75976791ce0',
164
+ },
165
+ [Env.testnet]: {
166
+ [SUI_TESTNET_CHAIN]:
167
+ '0x50454d0b0fbad1288a6ab74f2e8ce0905a3317870673ab7787ebcf6f322b45fa',
168
+ },
169
+ },
170
+ };
171
+
172
+ export const getSuiTokenAddress = (
173
+ chainId: SuiChain,
174
+ env = DEFAULT_ENV,
175
+ ): Address | undefined => {
176
+ return SUI_TOKEN_ADDRESSES[Token.LBTC]?.[env]?.[chainId] || undefined;
177
+ };
178
+
179
+ export const SOLANA_TOKEN_ADDRESSES: TokenAddresses<SolanaChain> = {
180
+ [Token.LBTC]: {
181
+ [Env.prod]: {
182
+ [SOLANA_MAINNET_CHAIN]: 'LomP48F7bLbKyMRHHsDVt7wuHaUQvQnVVspjcbfuAek',
183
+ },
184
+ [Env.testnet]: {
185
+ [SOLANA_TESTNET_CHAIN]: '79cscM6J9Af24TGGWcXyDf56fDLoodkyXdVy4R9aZ6C6',
186
+ },
187
+ [Env.stage]: {
188
+ [SOLANA_DEVNET_CHAIN]: 'HEY7PCJe3GB27UWdopuYb1xDbB5SNtTcYPxRjntvfBSA',
189
+ },
190
+ },
191
+ };
192
+
193
+ export const getSolanaTokenAddress = (
194
+ chainId: SolanaChain,
195
+ env = DEFAULT_ENV,
196
+ ): string | undefined => {
197
+ return SOLANA_TOKEN_ADDRESSES[Token.LBTC]?.[env]?.[chainId] || undefined;
198
+ };