@lombard.finance/sdk-solana 1.2.2 → 2.0.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 +48 -15
- package/dist/index.cjs +1 -1
- package/dist/index.js +37 -31
- package/dist/index2.cjs +57 -54
- package/dist/index2.js +7608 -7206
- package/package.json +2 -2
- package/src/const/errors.ts +0 -4
- package/src/const/getConfig.ts +43 -20
- package/src/const/rpcUrls.ts +2 -2
- package/src/idl/asset_router.json +548 -179
- package/src/idl/consortium.json +24 -43
- package/src/idl/mailbox.json +118 -107
- package/src/index.ts +1 -3
- package/src/services/SolanaServiceImpl.test.ts +123 -0
- package/src/services/SolanaServiceImpl.ts +53 -17
- package/src/stories/components/OutputSelector/OutputSelector.tsx +1 -0
- package/src/types/errors.ts +2 -0
- package/src/utils/createDebugLogger.ts +6 -13
- package/src/utils/errors.ts +2 -0
- package/src/utils/tokenAccount.ts +3 -1
- package/src/utils/transactions.ts +1 -1
- package/src/web3Sdk/claimToken/claimBtcb.ts +37 -28
- package/src/web3Sdk/claimToken/claimLbtcGmp.ts +66 -8
- package/src/web3Sdk/claimToken/claimToken.stories.tsx +2 -2
- package/src/web3Sdk/claimToken/claimToken.ts +20 -16
- package/src/web3Sdk/claimToken/constants.ts +5 -0
- package/src/web3Sdk/claimToken/index.ts +1 -0
- package/src/web3Sdk/claimToken/shared.ts +88 -80
- package/src/web3Sdk/deposit/deposit.stories.tsx +240 -0
- package/src/web3Sdk/deposit/deposit.test.ts +327 -0
- package/src/web3Sdk/deposit/deposit.ts +339 -0
- package/src/web3Sdk/deposit/index.ts +1 -0
- package/src/web3Sdk/getTokenFeeConfig/getTokenFeeConfig.stories.tsx +166 -0
- package/src/web3Sdk/getTokenFeeConfig/getTokenFeeConfig.test.ts +224 -0
- package/src/web3Sdk/getTokenFeeConfig/getTokenFeeConfig.ts +154 -0
- package/src/web3Sdk/getTokenFeeConfig/index.ts +11 -0
- package/src/web3Sdk/index.ts +3 -4
- package/src/web3Sdk/redeem/index.ts +1 -0
- package/src/web3Sdk/redeem/redeem.stories.tsx +226 -0
- package/src/web3Sdk/redeem/redeem.test.ts +327 -0
- package/src/web3Sdk/redeem/redeem.ts +352 -0
- package/src/web3Sdk/redeemToken/redeemBtcb.ts +174 -0
- package/src/web3Sdk/redeemToken/redeemForBtc.stories.tsx +35 -21
- package/src/web3Sdk/redeemToken/redeemForBtc.test.ts +306 -0
- package/src/web3Sdk/redeemToken/redeemForBtc.ts +54 -215
- package/src/web3Sdk/redeemToken/redeemLbtc.ts +174 -0
- package/src/web3Sdk/redeemToken/shared.test.ts +45 -0
- package/src/web3Sdk/redeemToken/shared.ts +97 -0
- package/src/web3Sdk/claimLBTC/claimLBTC.stories.tsx +0 -189
- package/src/web3Sdk/claimLBTC/claimLBTC.ts +0 -225
- package/src/web3Sdk/claimLBTC/index.ts +0 -1
- package/src/web3Sdk/claimLBTC/utils/generateDepositId.ts +0 -75
- package/src/web3Sdk/claimLBTC/utils/index.ts +0 -2
- package/src/web3Sdk/claimLBTC/utils/parseTransactionLogs.ts +0 -44
- package/src/web3Sdk/claimLBTC/utils/payloadUtils.ts +0 -58
- package/src/web3Sdk/claimLBTC/utils/postMintSignatures.ts +0 -50
- package/src/web3Sdk/unstakeLBTC/index.ts +0 -1
- package/src/web3Sdk/unstakeLBTC/unstakeLBTC.stories.tsx +0 -141
- package/src/web3Sdk/unstakeLBTC/unstakeLBTC.ts +0 -140
- /package/src/web3Sdk/{claimLBTC → claimToken}/utils/__tests__/signatureUtils.test.ts +0 -0
- /package/src/web3Sdk/{claimLBTC → claimToken}/utils/signatureUtils.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lombard.finance/sdk-solana",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Solana integration for the Lombard SDK - stake BTC and manage LBTC on Solana",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@layerzerolabs/lz-definitions": "^3.0.87",
|
|
65
65
|
"@layerzerolabs/lz-v2-utilities": "^3.0.87",
|
|
66
66
|
"@layerzerolabs/oft-v2-solana-sdk": "^3.0.87",
|
|
67
|
-
"@lombard.finance/sdk-common": "
|
|
67
|
+
"@lombard.finance/sdk-common": "4.0.0",
|
|
68
68
|
"@metaplex-foundation/umi": "^0.9.2",
|
|
69
69
|
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
|
|
70
70
|
"@metaplex-foundation/umi-signer-wallet-adapters": "^0.9.2",
|
package/src/const/errors.ts
CHANGED
|
@@ -76,7 +76,3 @@ export const CLAIM_REJECTED_ERROR = createSdkError({
|
|
|
76
76
|
message: 'LBTC claim operation was rejected.',
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
export const UNSTAKE_REJECTED_ERROR = createSdkError({
|
|
80
|
-
code: ErrorCode.UNSTAKE_REJECTED,
|
|
81
|
-
message: 'LBTC unstake operation was rejected.',
|
|
82
|
-
});
|
package/src/const/getConfig.ts
CHANGED
|
@@ -13,7 +13,7 @@ export const DEFAULT_ENV: Env = 'prod';
|
|
|
13
13
|
*/
|
|
14
14
|
export const envToNetwork: Record<Env, SolanaNetwork> = {
|
|
15
15
|
prod: SolanaNetwork.mainnet,
|
|
16
|
-
testnet: SolanaNetwork.
|
|
16
|
+
testnet: SolanaNetwork.devnet,
|
|
17
17
|
stage: SolanaNetwork.devnet,
|
|
18
18
|
dev: SolanaNetwork.devnet,
|
|
19
19
|
ibc: SolanaNetwork.devnet,
|
|
@@ -195,23 +195,23 @@ const testnetConfig: IConfig = {
|
|
|
195
195
|
lbtcTokenMint: '1BTCPX3qyFtBvhQvJaHntfzZfB8qcJmJXfoRnD3vAgh',
|
|
196
196
|
lbtcProgramId: '79cscM6J9Af24TGGWcXyDf56fDLoodkyXdVy4R9aZ6C6',
|
|
197
197
|
treasuryAddress: 'ASsctcXoo2kjbxpVJKMV3tu6Fe9725fvyWF5hUeiNYDT',
|
|
198
|
-
bascule:
|
|
198
|
+
bascule: '1111111111111111111111111111111111111111111',
|
|
199
199
|
basculeData: null,
|
|
200
200
|
admin: '6MKjyWZnkSMitJYAixvJzqhJiVsjTA3hYHX8aP9qNioj',
|
|
201
201
|
lzOftAdapter: '7AwaQPN3Sh3qHo2j44nvwmNgPS9FhDDbBcUXAdi12pk1',
|
|
202
202
|
lzOftStore: '8YN34wKaAc34BwFKxnUqQeRwWmfhbs4vYw2rnz2Z89sp',
|
|
203
203
|
lzMultisig: 'J3XK1JJTF6udknuLb15oUQhYbooUFiafhNxwYHAMxXE1',
|
|
204
204
|
lzEscrow: '8aNceYRuD5PR51o2pBnhw9cCktByixMPySUJrP3FexzA',
|
|
205
|
-
btcbTokenMint:
|
|
206
|
-
consortium:
|
|
207
|
-
mailbox:
|
|
208
|
-
assetRouter:
|
|
209
|
-
ratioOracle:
|
|
210
|
-
bridge:
|
|
211
|
-
lombardTokenPool:
|
|
205
|
+
btcbTokenMint: 'BTCb1Xy55DzwPMog9d3ztPau4nqXp6BhUrdGHjTrMYCn',
|
|
206
|
+
consortium: 'Lomfd3XZfPV8PyLkjuLVwpYhrBoGJdnYkm98HCgeYGC',
|
|
207
|
+
mailbox: 'Lomu595CAtJGF6mpnfeAJ7daZfVdHeRkAdKyfqzXqom',
|
|
208
|
+
assetRouter: 'Lom7TQyK45pTUjFmmsuLaBrMVQ5crggYnSuCrjm9ebr',
|
|
209
|
+
ratioOracle: 'LomWze3gBt8Y7RN3sspuh2jupqAQPUi4tuaLWDnf6CZ',
|
|
210
|
+
bridge: 'LombUtstgyrZUhjvi12hUnm7HG7CxhtanUv6hakuCm4',
|
|
211
|
+
lombardTokenPool: 'Lomi5fKsXdGrrW2M3JRbJx5DnT3zgmSEfYWMUPeNaAB',
|
|
212
212
|
ledgerChainId: '033bc7baf196ce32b8b9200518df11c35bad882fc6e3b6f45b4a8885f4c1281b',
|
|
213
|
-
solanaRoutingChainId:
|
|
214
|
-
bitcoinRoutingChainId:
|
|
213
|
+
solanaRoutingChainId: '0259db5080fc2c6d3bcf7ca90712d3c2e5e6c28f27f0dfbb9953bdb0894c03ab',
|
|
214
|
+
bitcoinRoutingChainId: 'ff000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6',
|
|
215
215
|
};
|
|
216
216
|
|
|
217
217
|
/**
|
|
@@ -228,16 +228,16 @@ const prodConfig: IConfig = {
|
|
|
228
228
|
lzOftStore: 'CQeKmXxoGog57U5jPyYz7YAo8AuLUdoDqxGTXtMPkMuc',
|
|
229
229
|
lzMultisig: '2YB3LPB4Tdb1ccmEFqhK3ZEKLFzCPayUwzEU5J1DXSzK',
|
|
230
230
|
lzEscrow: '6nc7pBpN82EeKFbcqRt7xVV2h8FNQGdiVnTb2TQvyv99',
|
|
231
|
-
btcbTokenMint:
|
|
232
|
-
consortium:
|
|
233
|
-
mailbox:
|
|
234
|
-
assetRouter:
|
|
235
|
-
ratioOracle:
|
|
236
|
-
bridge:
|
|
237
|
-
lombardTokenPool:
|
|
231
|
+
btcbTokenMint: 'BTCbKVgfW4xMqTWEmxVwc6pzg2c5YtQWxSpBuQDhUrpu',
|
|
232
|
+
consortium: 'LomuEULX7VPwCBVTjxsgFjBLz7HJwE8V1DyaSqXj1dc',
|
|
233
|
+
mailbox: 'Lomsq4ZNkZQGysC1pQc2NqNiAbXQm6C8nLmKcUoESEA',
|
|
234
|
+
assetRouter: 'Lom9TMiPbqkXk8ddFooUY1gbHqt87TCmVfTfv8AHgYx',
|
|
235
|
+
ratioOracle: 'LomyRmBeQiuqiwcPmr23RRA1SMLAuDEgj5tHHe7rsDn',
|
|
236
|
+
bridge: 'Lomva5kTftuXE8992qRufkaeq3XrXV47qv3C1W9xW6Z',
|
|
237
|
+
lombardTokenPool: 'Lomb8TTCwJKEhZrJ1J8UbsCRjNSf7NNQUEr4qo3dkSk',
|
|
238
238
|
ledgerChainId: '0387b25e8e61f2ce4838b04795b231f09ee73ffd391da018bef4bc5c4975897b',
|
|
239
|
-
solanaRoutingChainId:
|
|
240
|
-
bitcoinRoutingChainId:
|
|
239
|
+
solanaRoutingChainId: '02296998a6f8e2a784db5d9f95e18fc23f70441a1039446801089879b08c7ef0',
|
|
240
|
+
bitcoinRoutingChainId: 'ff0000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
|
|
241
241
|
};
|
|
242
242
|
|
|
243
243
|
/**
|
|
@@ -297,3 +297,26 @@ export function getLBTCAddress(envOrNetwork: Env | SolanaNetwork): string {
|
|
|
297
297
|
: networkToEnv[envOrNetwork as SolanaNetwork];
|
|
298
298
|
return getConfig(env).lbtcTokenMint;
|
|
299
299
|
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Get the BTC.b token address for a specific environment
|
|
303
|
+
* @param env Environment
|
|
304
|
+
* @returns BTC.b token address or null if not configured
|
|
305
|
+
*/
|
|
306
|
+
export function getBTCBAddress(env: Env): string | null;
|
|
307
|
+
export function getBTCBAddress(network: SolanaNetwork): string | null;
|
|
308
|
+
export function getBTCBAddress(
|
|
309
|
+
envOrNetwork: Env | SolanaNetwork,
|
|
310
|
+
): string | null {
|
|
311
|
+
const isEnv =
|
|
312
|
+
envOrNetwork === 'prod' ||
|
|
313
|
+
envOrNetwork === 'testnet' ||
|
|
314
|
+
envOrNetwork === 'stage' ||
|
|
315
|
+
envOrNetwork === 'dev' ||
|
|
316
|
+
envOrNetwork === 'ibc';
|
|
317
|
+
|
|
318
|
+
const env = isEnv
|
|
319
|
+
? envOrNetwork
|
|
320
|
+
: networkToEnv[envOrNetwork as SolanaNetwork];
|
|
321
|
+
return getConfig(env).btcbTokenMint;
|
|
322
|
+
}
|
package/src/const/rpcUrls.ts
CHANGED
|
@@ -14,13 +14,13 @@ export const BFF_WS_URL_STAGE =
|
|
|
14
14
|
export const RPC_URLS: Record<SolanaNetwork, string> = {
|
|
15
15
|
[SolanaNetwork.mainnet]: `${BFF_BASE_URL_PROD}/solana`,
|
|
16
16
|
[SolanaNetwork.testnet]: 'https://api.testnet.solana.com',
|
|
17
|
-
[SolanaNetwork.devnet]: `${
|
|
17
|
+
[SolanaNetwork.devnet]: `${BFF_BASE_URL_PROD}/solana_devnet`,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
export const WS_URLS: Record<SolanaNetwork, string> = {
|
|
21
21
|
[SolanaNetwork.mainnet]: `${BFF_WS_URL_PROD}?chain=solana`,
|
|
22
22
|
[SolanaNetwork.testnet]: 'wss://api.testnet.solana.com',
|
|
23
|
-
[SolanaNetwork.devnet]: `${
|
|
23
|
+
[SolanaNetwork.devnet]: `${BFF_BASE_URL_PROD}?chain=solana_devnet`,
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export const getRpcUrl = (network: SolanaNetwork) => {
|