@lombard.finance/sdk 2.1.2 → 2.2.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 +191 -69
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +300 -239
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/common/types/types.ts +6 -0
- package/src/sdk/getNetworkFeeSignature/getNetworkFeeSignature.stories.tsx +2 -2
- package/src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +2 -2
- package/src/sdk/index.ts +1 -0
- package/src/sdk/setReferral/index.ts +1 -0
- package/src/sdk/setReferral/setReferral.ts +61 -0
- package/src/sdk/storeNetworkFeeSignature/storeNetworkFeeSignature.stories.tsx +2 -2
- package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.stories.tsx +2 -2
- package/src/web3Sdk/abi/STAKE_AND_BAKE.json +15 -0
- package/src/web3Sdk/abi/index.ts +2 -1
- package/src/web3Sdk/basculeAddressConfig.ts +28 -9
- package/src/web3Sdk/getStakeAndBakeFee/getStakeAndBakeFee.stories.tsx +64 -0
- package/src/web3Sdk/getStakeAndBakeFee/getStakeAndBakeFee.tsx +48 -0
- package/src/web3Sdk/getStakeAndBakeFee/index.ts +1 -0
- package/src/web3Sdk/index.ts +1 -0
- package/src/web3Sdk/lbtcAddressConfig.ts +17 -1
- package/src/web3Sdk/signNetworkFee/signNetworkFee.stories.tsx +2 -2
- package/src/web3Sdk/signStakeAndBake/contracts.ts +7 -14
package/README.md
CHANGED
|
@@ -46,6 +46,8 @@ const { getDepositBtcAddress } = require('@lombard.finance/sdk');
|
|
|
46
46
|
- [getLBTCExchangeRate](#getLBTCExchangeRate)
|
|
47
47
|
- [storeStakeAndBakeSignature](#storeStakeAndBakeSignature)
|
|
48
48
|
- [getUserStakeAndBakeSignature](#getUserStakeAndBakeSignature)
|
|
49
|
+
- [storeNetworkFeeSignature](#storeNetworkFeeSignature)
|
|
50
|
+
- [getNetworkFeeSignature](#getNetworkFeeSignature)
|
|
49
51
|
- Web3 based
|
|
50
52
|
- [signLbtcDestionationAddr](#signLbtcDestionationAddr)
|
|
51
53
|
- [claimLBTC](#claimLBTC)
|
|
@@ -53,6 +55,8 @@ const { getDepositBtcAddress } = require('@lombard.finance/sdk');
|
|
|
53
55
|
- [getBasculeDepositStatus](#getBasculeDepositStatus)
|
|
54
56
|
- [getLBTCTotalSupply](#getLBTCTotalSupply)
|
|
55
57
|
- [signStakeAndBake](#signStakeAndBake)
|
|
58
|
+
- [getStakeAndBakeFee](#getStakeAndBakeFee)
|
|
59
|
+
- [signNetworkFee](#signNetworkFee)
|
|
56
60
|
|
|
57
61
|
#### getDepositBtcAddress
|
|
58
62
|
|
|
@@ -129,10 +133,10 @@ Returns all deposits for a given address.
|
|
|
129
133
|
|
|
130
134
|
Parameters:
|
|
131
135
|
|
|
132
|
-
| name
|
|
133
|
-
|
|
134
|
-
| `address` | `string` | The EVM address to get deposits for
|
|
135
|
-
| `env`
|
|
136
|
+
| name | type | description |
|
|
137
|
+
| --------- | -------- | --------------------------------------- |
|
|
138
|
+
| `address` | `string` | The EVM address to get deposits for |
|
|
139
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
136
140
|
|
|
137
141
|
Usage
|
|
138
142
|
|
|
@@ -152,11 +156,11 @@ Returns the exchange rate for LBTC.
|
|
|
152
156
|
|
|
153
157
|
Parameters:
|
|
154
158
|
|
|
155
|
-
| name
|
|
156
|
-
|
|
159
|
+
| name | type | description |
|
|
160
|
+
| --------- | ---------- | ------------------------------------------------------ |
|
|
157
161
|
| `chainId` | `TChainId` | The chain id of the asset to get the exchange rate for |
|
|
158
|
-
| `amount`
|
|
159
|
-
| `env`
|
|
162
|
+
| `amount` | `number` | The amount of the asset to get the exchange rate for |
|
|
163
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
160
164
|
|
|
161
165
|
Usage
|
|
162
166
|
|
|
@@ -178,11 +182,11 @@ Signing is necessary for the generation of the deposit address.
|
|
|
178
182
|
|
|
179
183
|
Parameters:
|
|
180
184
|
|
|
181
|
-
| name
|
|
182
|
-
|
|
185
|
+
| name | type | description |
|
|
186
|
+
| ---------- | ------------------ | ------------------------------ |
|
|
183
187
|
| `provider` | `IEIP1193Provider` | The EIP-1193 provider instance |
|
|
184
|
-
| `account`
|
|
185
|
-
| `chainId`
|
|
188
|
+
| `account` | `string` | Current account address |
|
|
189
|
+
| `chainId` | `TChainId` | Current chain ID |
|
|
186
190
|
|
|
187
191
|
Usage
|
|
188
192
|
|
|
@@ -206,14 +210,14 @@ Claims LBTC.
|
|
|
206
210
|
|
|
207
211
|
Parameters:
|
|
208
212
|
|
|
209
|
-
| name
|
|
210
|
-
|
|
211
|
-
| `data`
|
|
212
|
-
| `proofSignature` | `string`
|
|
213
|
-
| `provider`
|
|
214
|
-
| `account`
|
|
215
|
-
| `chainId`
|
|
216
|
-
| `env`
|
|
213
|
+
| name | type | description |
|
|
214
|
+
| ---------------- | ------------------ | -------------------------------------------------------------------------------------- |
|
|
215
|
+
| `data` | `string` | Raw payload from deposit notarization. Can be obtained from the `getDepositsByAddress` |
|
|
216
|
+
| `proofSignature` | `string` | Signature from deposit notarization. Can be obtained from the `getDepositsByAddress` |
|
|
217
|
+
| `provider` | `IEIP1193Provider` | The EIP-1193 provider instance |
|
|
218
|
+
| `account` | `string` | Current account address |
|
|
219
|
+
| `chainId` | `TChainId` | Current chain ID |
|
|
220
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
217
221
|
|
|
218
222
|
Usage
|
|
219
223
|
|
|
@@ -241,14 +245,14 @@ Unstakes LBTC to the specified BTC address.
|
|
|
241
245
|
|
|
242
246
|
Parameters:
|
|
243
247
|
|
|
244
|
-
| name
|
|
245
|
-
|
|
246
|
-
| `btcAddress` | `string`
|
|
247
|
-
| `amount`
|
|
248
|
-
| `provider`
|
|
249
|
-
| `account`
|
|
250
|
-
| `chainId`
|
|
251
|
-
| `env`
|
|
248
|
+
| name | type | description |
|
|
249
|
+
| ------------ | ------------------ | ------------------------------------------- |
|
|
250
|
+
| `btcAddress` | `string` | The BTC address to send the unstaked BTC to |
|
|
251
|
+
| `amount` | `string` | The amount of LBTC to unstake |
|
|
252
|
+
| `provider` | `IEIP1193Provider` | The EIP-1193 provider instance |
|
|
253
|
+
| `account` | `string` | Current account address |
|
|
254
|
+
| `chainId` | `TChainId` | Current chain ID |
|
|
255
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
252
256
|
|
|
253
257
|
Usage
|
|
254
258
|
|
|
@@ -276,13 +280,13 @@ Check Deposit Status by hash id through Bascule
|
|
|
276
280
|
|
|
277
281
|
Parameters:
|
|
278
282
|
|
|
279
|
-
| name
|
|
280
|
-
|
|
281
|
-
| `txId`
|
|
282
|
-
| `provider` | `IEIP1193Provider` | The EIP-1193 provider instance
|
|
283
|
-
| `account`
|
|
284
|
-
| `chainId`
|
|
285
|
-
| `env`
|
|
283
|
+
| name | type | description |
|
|
284
|
+
| ---------- | ------------------ | ---------------------------------------------------------------------------------- |
|
|
285
|
+
| `txId` | `string` | Payload from deposit notarization. Can be obtained from the `getDepositsByAddress` |
|
|
286
|
+
| `provider` | `IEIP1193Provider` | The EIP-1193 provider instance |
|
|
287
|
+
| `account` | `string` | Current account address |
|
|
288
|
+
| `chainId` | `TChainId` | Current chain ID |
|
|
289
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
286
290
|
|
|
287
291
|
Usage
|
|
288
292
|
|
|
@@ -307,11 +311,11 @@ Get LBTC total supply
|
|
|
307
311
|
|
|
308
312
|
Parameters:
|
|
309
313
|
|
|
310
|
-
| name
|
|
311
|
-
|
|
312
|
-
| `rpcUrl`
|
|
313
|
-
| `chainId` | `TChainId` | Current chain ID
|
|
314
|
-
| `env`
|
|
314
|
+
| name | type | description |
|
|
315
|
+
| --------- | ---------- | --------------------------------------- |
|
|
316
|
+
| `rpcUrl` | `string` | Rpc url for the chain |
|
|
317
|
+
| `chainId` | `TChainId` | Current chain ID |
|
|
318
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
315
319
|
|
|
316
320
|
Usage
|
|
317
321
|
|
|
@@ -333,15 +337,15 @@ Sign Stake And Bake
|
|
|
333
337
|
|
|
334
338
|
## Parameters
|
|
335
339
|
|
|
336
|
-
| name
|
|
337
|
-
|
|
338
|
-
| `provider`
|
|
339
|
-
| `address`
|
|
340
|
-
| `chainId`
|
|
341
|
-
| `value`
|
|
342
|
-
| `expiry`
|
|
343
|
-
| `rpcUrl`
|
|
344
|
-
| `vaultKey`
|
|
340
|
+
| name | type | description |
|
|
341
|
+
| ---------- | ------------------- | ------------------------------------------------- |
|
|
342
|
+
| `provider` | `IProvider` | Provider instance to interact with the blockchain |
|
|
343
|
+
| `address` | `string` | The address to sign with (owner) |
|
|
344
|
+
| `chainId` | `TChainId` | Chain ID for the signature |
|
|
345
|
+
| `value` | `string` | The value to approve |
|
|
346
|
+
| `expiry` | `number` | Expiry date as a unix timestamp |
|
|
347
|
+
| `rpcUrl` | `string` (optional) | Optional RPC URL for the network |
|
|
348
|
+
| `vaultKey` | `string` | The key of the vault to authorize |
|
|
345
349
|
|
|
346
350
|
Usage
|
|
347
351
|
|
|
@@ -354,7 +358,7 @@ const { signature, signatureData } = await signStakeAndBake({
|
|
|
354
358
|
chainId,
|
|
355
359
|
value: toSatoshi(approvalValue.toString()).toString(),
|
|
356
360
|
expiry: permitExpiryTime,
|
|
357
|
-
vaultKey: selectedVault.key
|
|
361
|
+
vaultKey: selectedVault.key,
|
|
358
362
|
});
|
|
359
363
|
```
|
|
360
364
|
|
|
@@ -366,19 +370,22 @@ Store stake and bake signature
|
|
|
366
370
|
|
|
367
371
|
## Parameters
|
|
368
372
|
|
|
369
|
-
| name
|
|
370
|
-
|
|
371
|
-
| `env`
|
|
372
|
-
| `signature`
|
|
373
|
-
| `typedData`
|
|
373
|
+
| name | type | description |
|
|
374
|
+
| ----------- | -------- | --------------------------------------- |
|
|
375
|
+
| `env` | `TEnv` | Environment (e.g., 'prod', 'stage', etc.) |
|
|
376
|
+
| `signature` | `string` | The generated signature |
|
|
377
|
+
| `typedData` | `string` | JSON typed data used for the signature |
|
|
374
378
|
|
|
375
379
|
Usage
|
|
376
380
|
|
|
377
381
|
```typescript
|
|
378
382
|
import { storeStakeAndBakeSignature } from '@lombard.finance/sdk';
|
|
379
383
|
|
|
380
|
-
const status = await storeStakeAndBakeSignature({
|
|
381
|
-
|
|
384
|
+
const status = await storeStakeAndBakeSignature({
|
|
385
|
+
signature,
|
|
386
|
+
signatureData,
|
|
387
|
+
env: 'prod',
|
|
388
|
+
});
|
|
382
389
|
```
|
|
383
390
|
|
|
384
391
|
#### getUserStakeAndBakeSignature
|
|
@@ -389,12 +396,11 @@ Get user's stake and bake signature from the API
|
|
|
389
396
|
|
|
390
397
|
## Parameters
|
|
391
398
|
|
|
392
|
-
| name
|
|
393
|
-
|
|
394
|
-
| `userDestinationAddress
|
|
395
|
-
| `chainId`
|
|
396
|
-
| `env`
|
|
397
|
-
|
|
399
|
+
| name | type | description |
|
|
400
|
+
| ------------------------ | -------- | --------------------------------------- |
|
|
401
|
+
| `userDestinationAddress` | `string` | The user's destination address |
|
|
402
|
+
| `chainId` | `string` | The chain ID |
|
|
403
|
+
| `env` | `TEnv` | Environment (e.g., 'prod', 'stage', etc.) |
|
|
398
404
|
|
|
399
405
|
Usage
|
|
400
406
|
|
|
@@ -404,21 +410,76 @@ import { getUserStakeAndBakeSignature } from '@lombard.finance/sdk';
|
|
|
404
410
|
const response = await getUserStakeAndBakeSignature({
|
|
405
411
|
userDestinationAddress: address,
|
|
406
412
|
chainId,
|
|
407
|
-
env: 'prod'
|
|
413
|
+
env: 'prod',
|
|
408
414
|
});
|
|
409
415
|
console.log(response);
|
|
410
416
|
```
|
|
411
417
|
|
|
418
|
+
#### storeNetworkFeeSignature
|
|
419
|
+
|
|
420
|
+
`@returns Promise<IStoreNetworkFeeSignatureResponse>` Response promise with statuses
|
|
421
|
+
|
|
422
|
+
Store authorize network fee
|
|
423
|
+
|
|
424
|
+
## Parameters
|
|
425
|
+
|
|
426
|
+
| name | type | description |
|
|
427
|
+
| ------------------------ | -------- | --------------------------------------- |
|
|
428
|
+
| `signature` | `string` | The signature of signNetworkFee method |
|
|
429
|
+
| `typedData` | `string` | JSON typed data used for the signature |
|
|
430
|
+
| `address` | `string` | Destination address |
|
|
431
|
+
| `env` | `TEnv` | Environment (e.g., 'prod', 'stage', etc.) |
|
|
432
|
+
|
|
433
|
+
Usage
|
|
434
|
+
|
|
435
|
+
```typescript
|
|
436
|
+
import { storeNetworkFeeSignature } from '@lombard.finance/sdk';
|
|
437
|
+
|
|
438
|
+
const status = await storeNetworkFeeSignature({
|
|
439
|
+
signature: '',
|
|
440
|
+
typedData: '',
|
|
441
|
+
address: '0x...',
|
|
442
|
+
env: 'prod',
|
|
443
|
+
});
|
|
444
|
+
console.log(status); // success
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
#### getNetworkFeeSignature
|
|
448
|
+
|
|
449
|
+
`@returns Promise<IStoreNetworkFeeSignatureResponse>` Response promise with statuses
|
|
450
|
+
|
|
451
|
+
Store authorize network fee
|
|
452
|
+
|
|
453
|
+
## Parameters
|
|
454
|
+
|
|
455
|
+
| name | type | description |
|
|
456
|
+
| ------------------------ | -------- | --------------------------------------- |
|
|
457
|
+
| `chainId` | `number` | The chain ID |
|
|
458
|
+
| `address` | `string` | Destination address |
|
|
459
|
+
| `env` | `TEnv` | Environment (e.g., 'prod', 'stage', etc.) |
|
|
460
|
+
|
|
461
|
+
Usage
|
|
462
|
+
|
|
463
|
+
```typescript
|
|
464
|
+
import { getNetworkFeeSignature } from '@lombard.finance/sdk';
|
|
465
|
+
|
|
466
|
+
const signatureResponse = await getNetworkFeeSignature({
|
|
467
|
+
chainId: 1,
|
|
468
|
+
address: '0x...',
|
|
469
|
+
env: 'prod',
|
|
470
|
+
});
|
|
471
|
+
console.log(signatureResponse);
|
|
472
|
+
```
|
|
473
|
+
|
|
412
474
|
#### getStakeAndBakeVaults
|
|
413
475
|
|
|
414
476
|
`@returns IStakeAndBakeVault[]` A list of available vaults
|
|
415
477
|
|
|
416
478
|
## Parameters
|
|
417
479
|
|
|
418
|
-
| name
|
|
419
|
-
|
|
420
|
-
| `chainId`
|
|
421
|
-
|
|
480
|
+
| name | type | description |
|
|
481
|
+
| --------- | -------- | ------------ |
|
|
482
|
+
| `chainId` | `string` | The chain ID |
|
|
422
483
|
|
|
423
484
|
Usage
|
|
424
485
|
|
|
@@ -428,4 +489,65 @@ import { getStakeAndBakeVaults } from '@lombard.finance/sdk';
|
|
|
428
489
|
const vaults = getStakeAndBakeVaults(1);
|
|
429
490
|
|
|
430
491
|
console.log(vaults);
|
|
431
|
-
```
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
#### getStakeAndBakeFee
|
|
495
|
+
|
|
496
|
+
`@returns Promise<string>` Promise that resolves stakeAndBake fee in satoshis
|
|
497
|
+
|
|
498
|
+
Get Stake and bake fee in satoshis
|
|
499
|
+
|
|
500
|
+
## Parameters
|
|
501
|
+
|
|
502
|
+
| name | type | description |
|
|
503
|
+
| -------------- | -------- | --------------------- |
|
|
504
|
+
| `vaultAddress` | `string` | The vault address |
|
|
505
|
+
| `chainId` | `string` | The chain ID |
|
|
506
|
+
| `rpcUrl` | `string` | Rpc url for the chain |
|
|
507
|
+
|
|
508
|
+
Usage
|
|
509
|
+
|
|
510
|
+
```typescript
|
|
511
|
+
import { getStakeAndBakeFee } from '@lombard.finance/sdk';
|
|
512
|
+
|
|
513
|
+
const response = await getStakeAndBakeFee({
|
|
514
|
+
chainId: OChainId.binanceSmartChain,
|
|
515
|
+
rpcUrl: 'https://rpc.ankr.com/bsc',
|
|
516
|
+
vaultAddress: '0xC8bbF6153D7Ba105f1399D992ebd32B0541996ef',
|
|
517
|
+
});
|
|
518
|
+
console.log(response);
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
#### signNetworkFee
|
|
522
|
+
|
|
523
|
+
`@returns Promise<ISignNetworkFeeResponse>` A promise that resolves to the signature and typed data
|
|
524
|
+
|
|
525
|
+
Signs the network fee transaction in the current account.
|
|
526
|
+
Signing is necessary for the auto-mint.
|
|
527
|
+
|
|
528
|
+
## Parameters
|
|
529
|
+
|
|
530
|
+
| name | type | description |
|
|
531
|
+
| ---------- | ----------- | ------------------------------------------------- |
|
|
532
|
+
| `address` | `string` | The user address |
|
|
533
|
+
| `fee` | `string` | The Authorization fee |
|
|
534
|
+
| `expiry` | `number` | Expiration time |
|
|
535
|
+
| `chainId` | `string` | The chain ID |
|
|
536
|
+
| `env` | `TEnv` | Environment (e.g., 'prod', 'stage', etc.) |
|
|
537
|
+
| `provider` | `IProvider` | Provider instance to interact with the blockchain |
|
|
538
|
+
|
|
539
|
+
Usage
|
|
540
|
+
|
|
541
|
+
```typescript
|
|
542
|
+
import { signNetworkFee } from '@lombard.finance/sdk';
|
|
543
|
+
|
|
544
|
+
const response = await signNetworkFee({
|
|
545
|
+
chainId: OChainId.binanceSmartChain,
|
|
546
|
+
address: '0x...',
|
|
547
|
+
provider: window.ethereum,
|
|
548
|
+
fee: toSatoshi('0.0001'),
|
|
549
|
+
expiry: Math.floor(Date.now() / 1000) + NETWORK_FEE_EXPIRATION_TIME_SECONDS,
|
|
550
|
+
env: 'prod',
|
|
551
|
+
});
|
|
552
|
+
console.log(response);
|
|
553
|
+
```
|