@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/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  var Y = Object.defineProperty;
2
2
  var Q = (e, t, n) => t in e ? Y(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var _ = (e, t, n) => (Q(e, typeof t != "symbol" ? t + "" : t, n), n);
4
- import w from "axios";
4
+ import A from "axios";
5
5
  import x from "bignumber.js";
6
- import $, { Web3 as G, utils as E } from "web3";
6
+ import Z, { Web3 as V, utils as E } from "web3";
7
7
  import * as ee from "@bitcoin-js/tiny-secp256k1-asmjs";
8
- import { initEccLib as te, payments as ne, networks as V, address as ae } from "bitcoinjs-lib";
8
+ import { initEccLib as te, payments as ne, networks as H, address as ae } from "bitcoinjs-lib";
9
9
  const l = {
10
10
  prod: "prod",
11
11
  testnet: "testnet",
@@ -18,16 +18,20 @@ const l = {
18
18
  sepolia: 11155111,
19
19
  base: 8453,
20
20
  baseSepoliaTestnet: 84532,
21
+ berachain: 80094,
21
22
  berachainBartioTestnet: 80084,
22
23
  corn: 21e6,
23
- swell: 1923
24
- }, se = (e) => e === l.prod ? i.ethereum : i.holesky, ie = (e) => e === l.prod ? i.binanceSmartChain : i.binanceSmartChainTestnet, re = (e) => e === l.prod ? i.base : i.baseSepoliaTestnet, P = l.prod, y = "0x0000000000000000000000000000000000000000", oe = {
24
+ swell: 1923,
25
+ sonic: 146,
26
+ morph: 2818,
27
+ morphHolesky: 2810
28
+ }, se = (e) => e === l.prod ? i.ethereum : i.holesky, ie = (e) => e === l.prod ? i.binanceSmartChain : i.binanceSmartChainTestnet, re = (e) => e === l.prod ? i.base : i.baseSepoliaTestnet, P = l.prod, u = "0x0000000000000000000000000000000000000000", oe = {
25
29
  baseApiUrl: "https://staging.prod.lombard.finance"
26
30
  }, pe = {
27
31
  baseApiUrl: "https://gastald-testnet.prod.lombard.finance"
28
32
  }, ue = {
29
33
  baseApiUrl: "https://mainnet.prod.lombard.finance"
30
- }, A = (e = P) => {
34
+ }, v = (e = P) => {
31
35
  switch (e) {
32
36
  case l.prod:
33
37
  return ue;
@@ -37,7 +41,7 @@ const l = {
37
41
  return oe;
38
42
  }
39
43
  };
40
- function v(e) {
44
+ function T(e) {
41
45
  return typeof e == "string" ? e : ((n) => {
42
46
  var a;
43
47
  return ((a = n == null ? void 0 : n.data) == null ? void 0 : a.message) && typeof n.data.message == "string";
@@ -49,7 +53,7 @@ function ye(e) {
49
53
  function de(e) {
50
54
  return e != null && e.message ? e.message : "Unknown error";
51
55
  }
52
- const g = {
56
+ const w = {
53
57
  eth: "DESTINATION_BLOCKCHAIN_ETHEREUM",
54
58
  ethOld: "BLOCKCHAIN_ETHEREUM",
55
59
  base: "DESTINATION_BLOCKCHAIN_BASE",
@@ -62,19 +66,19 @@ function O(e) {
62
66
  case i.ethereum:
63
67
  case i.holesky:
64
68
  case i.sepolia:
65
- return g.eth;
69
+ return w.eth;
66
70
  case i.base:
67
71
  case i.baseSepoliaTestnet:
68
- return g.base;
72
+ return w.base;
69
73
  case i.binanceSmartChain:
70
74
  case i.binanceSmartChainTestnet:
71
- return g.bsc;
75
+ return w.bsc;
72
76
  default:
73
77
  throw new Error(`Unknown chain ID: ${e}`);
74
78
  }
75
79
  }
76
- const le = "sanctioned_address", me = "api/v1/address/generate", ce = "destination address is under sanctions";
77
- async function it({
80
+ const le = "sanctioned_address", ce = "api/v1/address/generate", me = "destination address is under sanctions";
81
+ async function ot({
78
82
  address: e,
79
83
  chainId: t,
80
84
  signature: n,
@@ -83,38 +87,38 @@ async function it({
83
87
  referrerCode: r,
84
88
  partnerId: o,
85
89
  captchaToken: p,
86
- signatureData: u
90
+ signatureData: y
87
91
  }) {
88
- const { baseApiUrl: f } = A(s), m = O(t), T = {
92
+ const { baseApiUrl: f } = v(s), c = O(t), h = {
89
93
  to_address: e,
90
94
  to_address_signature: n,
91
- to_chain: m,
95
+ to_chain: c,
92
96
  partner_id: o,
93
97
  nonce: 0,
94
98
  captcha: p,
95
99
  referrer_code: r,
96
100
  eip_712_data: a,
97
- sb_signature_data: u
101
+ sb_signature_data: y
98
102
  };
99
103
  try {
100
- const { data: c } = await w.post(
101
- me,
102
- T,
104
+ const { data: m } = await A.post(
105
+ ce,
106
+ h,
103
107
  { baseURL: f }
104
108
  );
105
- return c.address;
106
- } catch (c) {
107
- const b = v(c);
109
+ return m.address;
110
+ } catch (m) {
111
+ const b = T(m);
108
112
  if (be(b))
109
113
  return le;
110
114
  throw new Error(b);
111
115
  }
112
116
  }
113
117
  function be(e) {
114
- return !!e.includes(ce);
118
+ return !!e.includes(me);
115
119
  }
116
120
  const fe = "api/v1/address";
117
- async function rt({
121
+ async function pt({
118
122
  address: e,
119
123
  chainId: t,
120
124
  env: n,
@@ -142,47 +146,47 @@ async function he({
142
146
  env: n,
143
147
  partnerId: a
144
148
  }) {
145
- const { baseApiUrl: s } = A(n), r = O(t), o = {
149
+ const { baseApiUrl: s } = v(n), r = O(t), o = {
146
150
  to_address: e,
147
151
  to_blockchain: r,
148
152
  limit: 1,
149
153
  offset: 0,
150
154
  asc: !1,
151
155
  referralId: a
152
- }, { data: p } = await w.get(fe, {
156
+ }, { data: p } = await A.get(fe, {
153
157
  baseURL: s,
154
158
  params: o
155
159
  });
156
160
  return (p == null ? void 0 : p.addresses) || [];
157
161
  }
158
162
  const ge = 8, F = 10 ** ge;
159
- function Z(e) {
163
+ function K(e) {
160
164
  return +e / F;
161
165
  }
162
- function K(e) {
166
+ function q(e) {
163
167
  return Math.floor(+e * F);
164
168
  }
165
169
  function we(e, t = P) {
166
170
  switch (e) {
167
- case g.eth:
168
- case g.ethOld:
171
+ case w.eth:
172
+ case w.ethOld:
169
173
  return se(t);
170
- case g.base:
171
- case g.baseOld:
174
+ case w.base:
175
+ case w.baseOld:
172
176
  return re(t);
173
- case g.bsc:
174
- case g.bscOld:
177
+ case w.bsc:
178
+ case w.bscOld:
175
179
  return ie(t);
176
180
  default:
177
181
  return i.ethereum;
178
182
  }
179
183
  }
180
184
  var Ae = /* @__PURE__ */ ((e) => (e.NOTARIZATION_STATUS_UNSPECIFIED = "NOTARIZATION_STATUS_UNSPECIFIED", e.NOTARIZATION_STATUS_PENDING = "NOTARIZATION_STATUS_PENDING", e.NOTARIZATION_STATUS_SUBMITTED = "NOTARIZATION_STATUS_SUBMITTED", e.NOTARIZATION_STATUS_SESSION_APPROVED = "NOTARIZATION_STATUS_SESSION_APPROVED", e.NOTARIZATION_STATUS_FAILED = "NOTARIZATION_STATUS_FAILED", e))(Ae || {}), ve = /* @__PURE__ */ ((e) => (e.SESSION_STATE_UNSPECIFIED = "SESSION_STATE_UNSPECIFIED", e.SESSION_STATE_PENDING = "SESSION_STATE_PENDING", e.SESSION_STATE_COMPLETED = "SESSION_STATE_COMPLETED", e.SESSION_STATE_EXPIRED = "SESSION_STATE_EXPIRED", e))(ve || {});
181
- async function ot({
185
+ async function ut({
182
186
  address: e,
183
187
  env: t
184
188
  }) {
185
- const { baseApiUrl: n } = A(t), { data: a } = await w.get(
189
+ const { baseApiUrl: n } = v(t), { data: a } = await A.get(
186
190
  `api/v1/address/outputs-v2/${e}`,
187
191
  { baseURL: n }
188
192
  );
@@ -194,7 +198,7 @@ function Ce(e) {
194
198
  index: t.index ?? 0,
195
199
  blockHeight: t.block_height ? Number(t.block_height) : void 0,
196
200
  blockTime: t.block_time ? Number(t.block_time) : void 0,
197
- value: new x(Z(t.value)),
201
+ value: new x(K(t.value)),
198
202
  address: t.address,
199
203
  chainId: we(t.to_chain, e),
200
204
  claimedTxId: t.claim_tx,
@@ -211,25 +215,25 @@ function Ce(e) {
211
215
  });
212
216
  }
213
217
  const Se = 2e-4;
214
- async function pt({
218
+ async function yt({
215
219
  env: e,
216
220
  chainId: t = i.ethereum,
217
221
  amount: n = 1
218
222
  }) {
219
- const { baseApiUrl: a } = A(e), s = O(t), { data: r } = await w.get(
223
+ const { baseApiUrl: a } = v(e), s = O(t), { data: r } = await A.get(
220
224
  `api/v1/exchange/rate/${s}`,
221
225
  { baseURL: a, params: { amount: n } }
222
226
  ), o = new x(Se).multipliedBy(F).toFixed();
223
227
  return { exchangeRate: +r.amount_out, minAmount: +o };
224
228
  }
225
- async function ut({
229
+ async function dt({
226
230
  address: e,
227
231
  chainId: t,
228
232
  env: n
229
233
  }) {
230
- const { baseApiUrl: a } = A(n);
234
+ const { baseApiUrl: a } = v(n);
231
235
  try {
232
- const { data: s } = await w.get(
236
+ const { data: s } = await A.get(
233
237
  `${a}/api/v1/claimer/get-user-signature`,
234
238
  {
235
239
  params: {
@@ -244,18 +248,18 @@ async function ut({
244
248
  isDelayed: s == null ? void 0 : s.is_delayed
245
249
  };
246
250
  } catch (s) {
247
- const r = v(s);
251
+ const r = T(s);
248
252
  throw new Error(r);
249
253
  }
250
254
  }
251
- async function yt({
255
+ async function lt({
252
256
  userDestinationAddress: e,
253
257
  chainId: t,
254
258
  env: n
255
259
  }) {
256
- const { baseApiUrl: a } = A(n);
260
+ const { baseApiUrl: a } = v(n);
257
261
  try {
258
- const { data: s } = await w.get(
262
+ const { data: s } = await A.get(
259
263
  `${a}/api/v1/claimer/get-user-stake-and-bake-signature`,
260
264
  {
261
265
  params: {
@@ -272,21 +276,21 @@ async function yt({
272
276
  chainId: s.chain_id
273
277
  };
274
278
  } catch (s) {
275
- const r = v(s);
279
+ const r = T(s);
276
280
  throw new Error(
277
281
  `Failed to get user stake and bake signature: ${r}`
278
282
  );
279
283
  }
280
284
  }
281
- async function dt({
285
+ async function ct({
282
286
  signature: e,
283
287
  typedData: t,
284
288
  address: n,
285
289
  env: a
286
290
  }) {
287
- const { baseApiUrl: s } = A(a);
291
+ const { baseApiUrl: s } = v(a);
288
292
  try {
289
- const { data: r } = await w.post(
293
+ const { data: r } = await A.post(
290
294
  `${s}/api/v1/claimer/save-user-signature`,
291
295
  null,
292
296
  {
@@ -299,18 +303,18 @@ async function dt({
299
303
  );
300
304
  return r.status;
301
305
  } catch (r) {
302
- const o = v(r);
306
+ const o = T(r);
303
307
  throw new Error(o);
304
308
  }
305
309
  }
306
- async function lt({
310
+ async function mt({
307
311
  signature: e,
308
312
  typedData: t,
309
313
  env: n
310
314
  }) {
311
- const { baseApiUrl: a } = A(n);
315
+ const { baseApiUrl: a } = v(n);
312
316
  try {
313
- const { data: s } = await w.post(
317
+ const { data: s } = await A.post(
314
318
  `${a}/api/v1/claimer/save-stake-and-bake-signature`,
315
319
  null,
316
320
  {
@@ -322,11 +326,34 @@ async function lt({
322
326
  );
323
327
  return s.status;
324
328
  } catch (s) {
325
- const r = v(s);
329
+ const r = T(s);
326
330
  throw new Error(r);
327
331
  }
328
332
  }
329
- const R = {
333
+ const Ee = "api/v1/referral-system/referrer/";
334
+ async function bt({
335
+ address: e,
336
+ signature: t,
337
+ eip712Data: n,
338
+ referrerCode: a,
339
+ env: s
340
+ }) {
341
+ const { baseApiUrl: r } = v(s), o = {
342
+ referrer_code: a,
343
+ signature: t,
344
+ signature_typed_data: n
345
+ };
346
+ try {
347
+ await A.post(`${Ee}${e}`, o, {
348
+ baseURL: r
349
+ });
350
+ return;
351
+ } catch (p) {
352
+ const y = T(p);
353
+ throw new Error(y);
354
+ }
355
+ }
356
+ const N = {
330
357
  [i.ethereum]: "https://rpc.ankr.com/eth",
331
358
  [i.holesky]: "https://rpc.ankr.com/eth_holesky",
332
359
  [i.sepolia]: "https://rpc.ankr.com/eth_sepolia",
@@ -335,7 +362,7 @@ const R = {
335
362
  [i.binanceSmartChain]: "https://bsc-dataseed.bnbchain.org",
336
363
  [i.binanceSmartChainTestnet]: "https://bsc-testnet-dataseed.bnbchain.org"
337
364
  };
338
- async function Ee(e) {
365
+ async function De(e) {
339
366
  const n = await (await fetch(e, {
340
367
  method: "POST",
341
368
  headers: {
@@ -347,15 +374,15 @@ async function Ee(e) {
347
374
  method: "eth_maxPriorityFeePerGas",
348
375
  params: []
349
376
  })
350
- })).json(), a = $.utils.hexToNumber(n == null ? void 0 : n.result);
377
+ })).json(), a = Z.utils.hexToNumber(n == null ? void 0 : n.result);
351
378
  return new x(Number(a));
352
379
  }
353
- const De = 2, _e = 25e3;
354
- class N {
380
+ const _e = 2, xe = 25e3;
381
+ class M {
355
382
  constructor({ chainId: t, rpcUrlConfig: n }) {
356
383
  _(this, "chainId");
357
384
  _(this, "rpcConfig");
358
- this.chainId = t, this.rpcConfig = { ...R, ...n };
385
+ this.chainId = t, this.rpcConfig = { ...N, ...n };
359
386
  }
360
387
  /**
361
388
  * Returns web3 instance for read operations.
@@ -364,7 +391,7 @@ class N {
364
391
  * @returns {Web3} Web3 instance.
365
392
  */
366
393
  getReadWeb3() {
367
- const t = this.getRpcUrl(), n = new G(), a = new G.providers.HttpProvider(t);
394
+ const t = this.getRpcUrl(), n = new V(), a = new V.providers.HttpProvider(t);
368
395
  return n.setProvider(a), n;
369
396
  }
370
397
  /**
@@ -392,10 +419,10 @@ class N {
392
419
  async getMaxFees() {
393
420
  const t = this.getReadWeb3(), n = this.getRpcUrl(), [a, s] = await Promise.all([
394
421
  t.eth.getBlock("latest"),
395
- Ee(n)
422
+ De(n)
396
423
  ]);
397
424
  return !(a != null && a.baseFeePerGas) && typeof (a == null ? void 0 : a.baseFeePerGas) != "bigint" ? {} : {
398
- maxFeePerGas: +new x(a.baseFeePerGas.toString(10)).multipliedBy(De).plus(s),
425
+ maxFeePerGas: +new x(a.baseFeePerGas.toString(10)).multipliedBy(_e).plus(s),
399
426
  maxPriorityFeePerGas: +s
400
427
  };
401
428
  }
@@ -408,7 +435,7 @@ class N {
408
435
  async getSafeGasPriceWei() {
409
436
  const t = await this.getReadWeb3().eth.getGasPrice();
410
437
  return new x(t.toString(10)).plus(
411
- _e
438
+ xe
412
439
  );
413
440
  }
414
441
  /**
@@ -424,13 +451,13 @@ class N {
424
451
  return new a.eth.Contract(t, n);
425
452
  }
426
453
  }
427
- class D extends N {
454
+ class D extends M {
428
455
  constructor({ provider: n, account: a, chainId: s, rpcUrlConfig: r }) {
429
456
  super({ chainId: s, rpcUrlConfig: r });
430
457
  _(this, "web3");
431
458
  _(this, "account");
432
- _(this, "rpcConfig", R);
433
- this.web3 = new $(n), this.account = a, this.chainId = s, this.rpcConfig = { ...R, ...r };
459
+ _(this, "rpcConfig", N);
460
+ this.web3 = new Z(n), this.account = a, this.chainId = s, this.rpcConfig = { ...N, ...r };
434
461
  }
435
462
  /**
436
463
  * Signs a message using the current provider and account.
@@ -456,11 +483,11 @@ class D extends N {
456
483
  */
457
484
  async sendTransactionAsync(n, a, s) {
458
485
  const { chainId: r, web3: o } = this, p = this.getReadWeb3(), {
459
- data: u,
486
+ data: y,
460
487
  estimate: f = !1,
461
- estimateFee: m = !1,
462
- extendedGasLimit: T,
463
- gasLimit: c = "0",
488
+ estimateFee: c = !1,
489
+ extendedGasLimit: h,
490
+ gasLimit: m = "0",
464
491
  value: b = "0",
465
492
  gasLimitMultiplier: I = 1
466
493
  } = s;
@@ -470,40 +497,40 @@ class D extends N {
470
497
  from: n,
471
498
  to: a,
472
499
  value: E.numberToHex(b),
473
- data: u,
500
+ data: y,
474
501
  nonce: S,
475
502
  chainId: E.numberToHex(r)
476
503
  };
477
504
  if (f)
478
505
  try {
479
- const h = await p.eth.estimateGas(d), M = Math.round(
480
- Number(h) * I
506
+ const g = await p.eth.estimateGas(d), R = Math.round(
507
+ Number(g) * I
481
508
  );
482
- T ? d.gas = E.numberToHex(M + T) : d.gas = E.numberToHex(M);
483
- } catch (h) {
509
+ h ? d.gas = E.numberToHex(R + h) : d.gas = E.numberToHex(R);
510
+ } catch (g) {
484
511
  throw new Error(
485
- h.message ?? "Failed to estimate gas limit for transaction."
512
+ g.message ?? "Failed to estimate gas limit for transaction."
486
513
  );
487
514
  }
488
515
  else
489
- d.gas = E.numberToHex(c);
490
- const { maxFeePerGas: U, maxPriorityFeePerGas: B } = m ? await this.getMaxFees().catch(() => s) : s;
491
- if (B !== void 0 && (d.maxPriorityFeePerGas = E.numberToHex(B)), U !== void 0 && (d.maxFeePerGas = E.numberToHex(U)), !d.maxFeePerGas && !d.maxPriorityFeePerGas) {
492
- const h = await this.getSafeGasPriceWei();
493
- d.gasPrice = h.toString(10);
516
+ d.gas = E.numberToHex(m);
517
+ const { maxFeePerGas: U, maxPriorityFeePerGas: L } = c ? await this.getMaxFees().catch(() => s) : s;
518
+ if (L !== void 0 && (d.maxPriorityFeePerGas = E.numberToHex(L)), U !== void 0 && (d.maxFeePerGas = E.numberToHex(U)), !d.maxFeePerGas && !d.maxPriorityFeePerGas) {
519
+ const g = await this.getSafeGasPriceWei();
520
+ d.gasPrice = g.toString(10);
494
521
  }
495
522
  if (!d.maxFeePerGas && !d.maxPriorityFeePerGas) {
496
- const h = await this.getSafeGasPriceWei();
497
- d.gasPrice = h.toString(10);
523
+ const g = await this.getSafeGasPriceWei();
524
+ d.gasPrice = g.toString(10);
498
525
  }
499
- return console.log("Sending transaction via Web3: ", d), new Promise((h, M) => {
500
- const L = o.eth.sendTransaction(d);
501
- L.once("transactionHash", async (W) => {
502
- console.log(`Just signed transaction has is: ${W}`), h({
503
- receiptPromise: L,
504
- transactionHash: W
526
+ return console.log("Sending transaction via Web3: ", d), new Promise((g, R) => {
527
+ const W = o.eth.sendTransaction(d);
528
+ W.once("transactionHash", async (G) => {
529
+ console.log(`Just signed transaction has is: ${G}`), g({
530
+ receiptPromise: W,
531
+ transactionHash: G
505
532
  });
506
- }).catch(M);
533
+ }).catch(R);
507
534
  });
508
535
  }
509
536
  createContract(n, a) {
@@ -524,51 +551,63 @@ function k(e) {
524
551
  function z(e) {
525
552
  return Object.values(i).includes(e);
526
553
  }
527
- const xe = {
554
+ const Me = {
528
555
  [i.holesky]: "0xED7bfd5C1790576105Af4649817f6d35A75CD818",
529
- [i.ethereum]: y,
556
+ [i.ethereum]: u,
530
557
  [i.binanceSmartChainTestnet]: "0x731eFa688F3679688cf60A3993b8658138953ED6",
531
- [i.binanceSmartChain]: y,
558
+ [i.binanceSmartChain]: u,
532
559
  [i.sepolia]: "0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",
533
- [i.base]: y,
560
+ [i.base]: u,
534
561
  [i.baseSepoliaTestnet]: "0x731eFa688F3679688cf60A3993b8658138953ED6",
562
+ [i.berachain]: u,
535
563
  [i.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
536
- [i.corn]: y,
537
- [i.swell]: y
564
+ [i.corn]: u,
565
+ [i.swell]: u,
566
+ [i.sonic]: u,
567
+ [i.morph]: u,
568
+ [i.morphHolesky]: u
538
569
  }, Ie = {
539
570
  [i.holesky]: "0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",
540
- [i.ethereum]: y,
571
+ [i.ethereum]: u,
541
572
  [i.binanceSmartChainTestnet]: "0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",
542
- [i.binanceSmartChain]: y,
573
+ [i.binanceSmartChain]: u,
543
574
  [i.sepolia]: "0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",
544
- [i.base]: y,
545
- [i.baseSepoliaTestnet]: y,
575
+ [i.base]: u,
576
+ [i.baseSepoliaTestnet]: u,
577
+ [i.berachain]: u,
546
578
  [i.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
547
- [i.corn]: y,
548
- [i.swell]: y
549
- }, Me = {
579
+ [i.corn]: u,
580
+ [i.swell]: u,
581
+ [i.sonic]: u,
582
+ [i.morph]: u,
583
+ [i.morphHolesky]: u
584
+ }, Re = {
550
585
  [i.ethereum]: "0x8236a87084f8b84306f72007f36f2618a5634494",
551
- [i.holesky]: y,
552
- [i.sepolia]: y,
553
- [i.binanceSmartChainTestnet]: y,
586
+ [i.holesky]: u,
587
+ [i.sepolia]: u,
588
+ [i.binanceSmartChainTestnet]: u,
554
589
  [i.binanceSmartChain]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
555
590
  [i.base]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
556
- [i.baseSepoliaTestnet]: y,
557
- [i.berachainBartioTestnet]: y,
591
+ [i.baseSepoliaTestnet]: u,
592
+ [i.berachain]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
593
+ [i.berachainBartioTestnet]: u,
558
594
  [i.corn]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
559
- [i.swell]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1"
595
+ [i.swell]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
596
+ [i.sonic]: u,
597
+ [i.morph]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
598
+ [i.morphHolesky]: u
560
599
  };
561
- function q(e = P) {
600
+ function j(e = P) {
562
601
  switch (e) {
563
602
  case l.prod:
564
- return Me;
603
+ return Re;
565
604
  case l.testnet:
566
605
  return Ie;
567
606
  default:
568
- return xe;
607
+ return Me;
569
608
  }
570
609
  }
571
- const Re = [
610
+ const Ne = [
572
611
  {
573
612
  constant: !0,
574
613
  inputs: [],
@@ -789,7 +828,7 @@ const Re = [
789
828
  name: "Transfer",
790
829
  type: "event"
791
830
  }
792
- ], Ne = [
831
+ ], Pe = [
793
832
  {
794
833
  inputs: [],
795
834
  stateMutability: "nonpayable",
@@ -2549,7 +2588,7 @@ const Re = [
2549
2588
  stateMutability: "nonpayable",
2550
2589
  type: "function"
2551
2590
  }
2552
- ], Pe = [
2591
+ ], Oe = [
2553
2592
  {
2554
2593
  inputs: [
2555
2594
  {
@@ -3398,32 +3437,46 @@ const Re = [
3398
3437
  stateMutability: "nonpayable",
3399
3438
  type: "function"
3400
3439
  }
3440
+ ], Fe = [
3441
+ {
3442
+ inputs: [],
3443
+ name: "getStakeAndBakeFee",
3444
+ outputs: [
3445
+ {
3446
+ internalType: "uint256",
3447
+ name: "",
3448
+ type: "uint256"
3449
+ }
3450
+ ],
3451
+ stateMutability: "view",
3452
+ type: "function"
3453
+ }
3401
3454
  ];
3402
- function Oe(e) {
3455
+ function ke(e) {
3403
3456
  switch (e) {
3404
3457
  case "LBTC":
3405
- return Ne;
3458
+ return Pe;
3406
3459
  default:
3407
- return Re;
3460
+ return Ne;
3408
3461
  }
3409
3462
  }
3410
3463
  function C(e, t) {
3411
- const n = q(t), { chainId: a } = e;
3464
+ const n = j(t), { chainId: a } = e;
3412
3465
  if (!z(a))
3413
3466
  throw new Error(`This chain ${a} is not supported`);
3414
3467
  const s = n[a];
3415
3468
  if (!s)
3416
3469
  throw new Error(`Token address for chain ${a} is not defined`);
3417
- const r = Oe("LBTC"), o = e.createContract(r, s);
3470
+ const r = ke("LBTC"), o = e.createContract(r, s);
3418
3471
  return o.options.address || (o.options.address = s), o;
3419
3472
  }
3420
- function mt({
3473
+ function ft({
3421
3474
  spender: e,
3422
3475
  amount: t,
3423
3476
  env: n,
3424
3477
  ...a
3425
3478
  }) {
3426
- const s = new D(a), r = C(s, n), o = K(t), p = r.methods.approve(e, o);
3479
+ const s = new D(a), r = C(s, n), o = q(t), p = r.methods.approve(e, o);
3427
3480
  return s.sendTransactionAsync(
3428
3481
  s.account,
3429
3482
  r.options.address,
@@ -3435,14 +3488,14 @@ function mt({
3435
3488
  }
3436
3489
  );
3437
3490
  }
3438
- const Fe = "insufficient funds", ke = "Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.", H = (e) => e.startsWith("0x") ? e : "0x" + e;
3439
- async function ct({
3491
+ const Be = "insufficient funds", Ue = "Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.", $ = (e) => e.startsWith("0x") ? e : "0x" + e;
3492
+ async function Tt({
3440
3493
  data: e,
3441
3494
  proofSignature: t,
3442
3495
  env: n,
3443
3496
  ...a
3444
3497
  }) {
3445
- const s = new D(a), r = C(s, n), o = r.methods.mint(H(e), H(t));
3498
+ const s = new D(a), r = C(s, n), o = r.methods.mint($(e), $(t));
3446
3499
  try {
3447
3500
  return await s.sendTransactionAsync(
3448
3501
  s.account,
@@ -3456,86 +3509,86 @@ async function ct({
3456
3509
  );
3457
3510
  } catch (p) {
3458
3511
  console.log("error", p);
3459
- const u = v(p);
3460
- throw u.includes(Fe) ? new Error(ke) : new Error(u);
3512
+ const y = T(p);
3513
+ throw y.includes(Be) ? new Error(Ue) : new Error(y);
3461
3514
  }
3462
3515
  }
3463
- function Ue(e, t) {
3516
+ function Le(e, t) {
3464
3517
  if (!t)
3465
3518
  throw new Error("The address for bascule module is not defined");
3466
- const n = e.createContract(Pe, t);
3519
+ const n = e.createContract(Oe, t);
3467
3520
  return n.options.address || (n.options.address = t), n;
3468
3521
  }
3469
- const Be = "No deposit ID provided. Please provide a deposit ID as an argument.";
3470
- var Le = /* @__PURE__ */ ((e) => (e[e.UNREPORTED = 0] = "UNREPORTED", e[e.REPORTED = 1] = "REPORTED", e[e.WITHDRAWN = 2] = "WITHDRAWN", e))(Le || {});
3471
- async function bt({
3522
+ const We = "No deposit ID provided. Please provide a deposit ID as an argument.";
3523
+ var Ge = /* @__PURE__ */ ((e) => (e[e.UNREPORTED = 0] = "UNREPORTED", e[e.REPORTED = 1] = "REPORTED", e[e.WITHDRAWN = 2] = "WITHDRAWN", e))(Ge || {});
3524
+ async function ht({
3472
3525
  rawPayload: e,
3473
3526
  env: t,
3474
3527
  ...n
3475
3528
  }) {
3476
3529
  if (!e)
3477
- throw new Error(Be);
3530
+ throw new Error(We);
3478
3531
  const a = new D(n), r = await C(a, t).methods.Bascule().call();
3479
- if (r === y)
3532
+ if (r === u)
3480
3533
  return 1;
3481
- const o = Ue(a, r);
3534
+ const o = Le(a, r);
3482
3535
  try {
3483
3536
  const p = a.getReadWeb3().utils.keccak256(
3484
3537
  Buffer.from(e.slice(8), "hex")
3485
- ), u = await o.methods.depositHistory(p).call();
3486
- return Number(u);
3538
+ ), y = await o.methods.depositHistory(p).call();
3539
+ return Number(y);
3487
3540
  } catch (p) {
3488
- const u = v(p);
3489
- throw new Error(u);
3541
+ const y = T(p);
3542
+ throw new Error(y);
3490
3543
  }
3491
3544
  }
3492
- const We = [
3545
+ const Ve = [
3493
3546
  i.ethereum,
3494
3547
  i.base,
3495
3548
  i.binanceSmartChain
3496
- ], j = (e) => We.includes(e) ? l.prod : l.stage;
3497
- function J(e, t) {
3549
+ ], J = (e) => Ve.includes(e) ? l.prod : l.stage;
3550
+ function B(e, t) {
3498
3551
  if (!z(e))
3499
3552
  throw new Error(`This chain ${e} is not supported`);
3500
- const n = t ? { [e]: t } : R;
3553
+ const n = t ? { [e]: t } : N;
3501
3554
  if (!n[e])
3502
3555
  throw new Error(`RPC URL for chainId ${e} not found`);
3503
3556
  return n;
3504
3557
  }
3505
- async function ft({
3558
+ async function gt({
3506
3559
  chainId: e,
3507
3560
  rpcUrl: t
3508
3561
  }) {
3509
- const n = J(e, t), a = new N({ chainId: e, rpcUrlConfig: n }), s = j(e), o = await C(a, s).methods.getMintFee().call();
3510
- return new x(Z(o.toString(10)));
3562
+ const n = B(e, t), a = new M({ chainId: e, rpcUrlConfig: n }), s = J(e), o = await C(a, s).methods.getMintFee().call();
3563
+ return new x(K(o.toString(10)));
3511
3564
  }
3512
- async function Tt({
3565
+ async function wt({
3513
3566
  env: e,
3514
3567
  rpcUrl: t,
3515
3568
  chainId: n
3516
3569
  }) {
3517
- const a = { [n]: t }, s = new N({ chainId: n, rpcUrlConfig: a });
3570
+ const a = { [n]: t }, s = new M({ chainId: n, rpcUrlConfig: a });
3518
3571
  return (await C(s, e).methods.totalSupply().call()).toString();
3519
3572
  }
3520
- async function Ge({
3573
+ async function He({
3521
3574
  owner: e,
3522
3575
  rpcUrl: t,
3523
3576
  chainId: n
3524
3577
  }) {
3525
- const a = J(n, t), s = new N({ chainId: n, rpcUrlConfig: a }), r = j(n), o = C(s, r);
3578
+ const a = B(n, t), s = new M({ chainId: n, rpcUrlConfig: a }), r = J(n), o = C(s, r);
3526
3579
  try {
3527
3580
  return (await o.methods.nonces(e).call()).toString();
3528
3581
  } catch (p) {
3529
- const u = v(p);
3530
- throw new Error(u);
3582
+ const y = T(p);
3583
+ throw new Error(y);
3531
3584
  }
3532
3585
  }
3533
- async function ht(e) {
3586
+ async function At(e) {
3534
3587
  const t = new D(e), n = `destination chain id is ${e.chainId}`;
3535
3588
  return t.signMessage(n);
3536
3589
  }
3537
- const Ve = 24 * 60 * 60;
3538
- function He({
3590
+ const $e = 24 * 60 * 60;
3591
+ function Ze({
3539
3592
  chainId: e,
3540
3593
  verifyingContract: t,
3541
3594
  fee: n,
@@ -3569,36 +3622,36 @@ function He({
3569
3622
  }
3570
3623
  };
3571
3624
  }
3572
- const $e = "Failed to obtain a valid signature. The response is undefined or invalid.", Ze = () => Math.floor(Date.now() / 1e3 + Ve);
3573
- async function gt({
3625
+ const Ke = "Failed to obtain a valid signature. The response is undefined or invalid.", qe = () => Math.floor(Date.now() / 1e3 + $e);
3626
+ async function vt({
3574
3627
  address: e,
3575
3628
  provider: t,
3576
3629
  fee: n,
3577
3630
  chainId: a,
3578
3631
  env: s,
3579
- expiry: r = Ze()
3632
+ expiry: r = qe()
3580
3633
  }) {
3581
- var T, c;
3634
+ var h, m;
3582
3635
  const o = new D({
3583
3636
  provider: t,
3584
3637
  account: e,
3585
3638
  chainId: a
3586
- }), u = C(o, s).options.address, f = JSON.stringify(
3587
- He({
3639
+ }), y = C(o, s).options.address, f = JSON.stringify(
3640
+ Ze({
3588
3641
  chainId: a,
3589
- verifyingContract: u,
3642
+ verifyingContract: y,
3590
3643
  fee: n,
3591
3644
  expiry: r
3592
3645
  })
3593
- ), m = await ((c = (T = o.web3) == null ? void 0 : T.currentProvider) == null ? void 0 : c.request({
3646
+ ), c = await ((m = (h = o.web3) == null ? void 0 : h.currentProvider) == null ? void 0 : m.request({
3594
3647
  method: "eth_signTypedData_v4",
3595
3648
  params: [e, f]
3596
3649
  }));
3597
- if (typeof m == "string")
3598
- return { signature: m, typedData: f };
3599
- if (!(m != null && m.result))
3600
- throw new Error($e);
3601
- return { signature: m.result, typedData: f };
3650
+ if (typeof c == "string")
3651
+ return { signature: c, typedData: f };
3652
+ if (!(c != null && c.result))
3653
+ throw new Error(Ke);
3654
+ return { signature: c.result, typedData: f };
3602
3655
  }
3603
3656
  const X = {
3604
3657
  [i.holesky]: [
@@ -3608,13 +3661,13 @@ const X = {
3608
3661
  address: "0x4A3cD83CEbb91E0Cd31EdA2Ee0F4AebfcCFCbBb6"
3609
3662
  }
3610
3663
  ],
3611
- // [OChainId.ethereum]: [
3612
- // {
3613
- // key: 'veda',
3614
- // name: 'Veda / Lombard DeFi Vault',
3615
- // address: '0x5401b8620e5fb570064ca9114fd1e135fd77d57c',
3616
- // },
3617
- // ],
3664
+ [i.ethereum]: [
3665
+ {
3666
+ key: "veda",
3667
+ name: "Veda / Lombard DeFi Vault",
3668
+ address: "0xC8bbF6153D7Ba105f1399D992ebd32B0541996ef"
3669
+ }
3670
+ ],
3618
3671
  [i.binanceSmartChain]: [
3619
3672
  {
3620
3673
  key: "veda",
@@ -3629,29 +3682,22 @@ const X = {
3629
3682
  address: "0x72143309A662bDB4aad5cA65Ab59eD8977D047C5"
3630
3683
  }
3631
3684
  ]
3632
- // [OChainId.base]: [
3633
- // {
3634
- // key: 'veda',
3635
- // name: 'Veda / Lombard DeFi Vault',
3636
- // address: '0x5401b8620e5fb570064ca9114fd1e135fd77d57c',
3637
- // },
3638
- // ],
3639
- }, wt = Object.keys(
3685
+ }, Ct = Object.keys(
3640
3686
  X
3641
- ).map(Number), Ke = (e) => {
3687
+ ).map(Number), ze = (e) => {
3642
3688
  const t = X[e];
3643
3689
  if (!(t != null && t.length))
3644
3690
  throw new Error(`No vaults configured for chain ID ${e}`);
3645
3691
  return t;
3646
- }, ze = (e, t) => {
3647
- const a = Ke(e).find((s) => s.key === t);
3692
+ }, je = (e, t) => {
3693
+ const a = ze(e).find((s) => s.key === t);
3648
3694
  if (!a)
3649
3695
  throw new Error(
3650
3696
  `No vault found with key ${t} for chain ID ${e}`
3651
3697
  );
3652
3698
  return a.address;
3653
3699
  };
3654
- async function qe({
3700
+ async function Je({
3655
3701
  chainId: e,
3656
3702
  expiry: t,
3657
3703
  owner: n,
@@ -3660,7 +3706,7 @@ async function qe({
3660
3706
  rpcUrl: r,
3661
3707
  verifyingContract: o
3662
3708
  }) {
3663
- const p = await Ge({
3709
+ const p = await He({
3664
3710
  owner: n,
3665
3711
  chainId: e,
3666
3712
  rpcUrl: r
@@ -3709,15 +3755,15 @@ async function qe({
3709
3755
  }
3710
3756
  };
3711
3757
  }
3712
- const je = (e, t = l.prod) => {
3713
- const a = q(t)[e];
3758
+ const Xe = (e, t = l.prod) => {
3759
+ const a = j(t)[e];
3714
3760
  if (!a)
3715
3761
  throw new Error(
3716
3762
  `No LBTC contract address configured for chain ID ${e}`
3717
3763
  );
3718
3764
  return a;
3719
- }, Je = "Failed to obtain a valid signature. The response is undefined or invalid.";
3720
- async function At({
3765
+ }, Ye = "Failed to obtain a valid signature. The response is undefined or invalid.";
3766
+ async function St({
3721
3767
  address: e,
3722
3768
  provider: t,
3723
3769
  chainId: n,
@@ -3728,72 +3774,85 @@ async function At({
3728
3774
  env: p
3729
3775
  }) {
3730
3776
  var I, S;
3731
- const u = new D({
3777
+ const y = new D({
3732
3778
  provider: t,
3733
3779
  account: e,
3734
3780
  chainId: n
3735
- }), f = je(n, p), m = ze(n, o), T = await qe({
3781
+ }), f = Xe(n, p), c = je(n, o), h = await Je({
3736
3782
  chainId: n,
3737
3783
  expiry: s,
3738
3784
  owner: e,
3739
- spender: m,
3785
+ spender: c,
3740
3786
  value: a,
3741
3787
  rpcUrl: r,
3742
3788
  verifyingContract: f
3743
- }), c = JSON.stringify(T), b = await ((S = (I = u.web3) == null ? void 0 : I.currentProvider) == null ? void 0 : S.request({
3789
+ }), m = JSON.stringify(h), b = await ((S = (I = y.web3) == null ? void 0 : I.currentProvider) == null ? void 0 : S.request({
3744
3790
  method: "eth_signTypedData_v4",
3745
- params: [e, c]
3791
+ params: [e, m]
3746
3792
  }));
3747
3793
  if (typeof b == "string")
3748
- return { signature: b, typedData: c };
3794
+ return { signature: b, typedData: m };
3749
3795
  if (!(b != null && b.result))
3750
- throw new Error(Je);
3751
- return { signature: b.result, typedData: c };
3796
+ throw new Error(Ye);
3797
+ return { signature: b.result, typedData: m };
3752
3798
  }
3753
3799
  te(ee);
3754
- function Xe(e, t = l.prod) {
3800
+ function Qe(e, t = l.prod) {
3755
3801
  var r;
3756
- const n = Ye(e), s = (r = ne[n]({
3802
+ const n = et(e), s = (r = ne[n]({
3757
3803
  address: e,
3758
- network: t === l.prod ? V.bitcoin : V.testnet
3804
+ network: t === l.prod ? H.bitcoin : H.testnet
3759
3805
  }).output) == null ? void 0 : r.toString("hex");
3760
3806
  if (!s)
3761
3807
  throw new Error("Output script is not found.");
3762
3808
  return `0x${s}`;
3763
3809
  }
3764
- function Ye(e) {
3810
+ function et(e) {
3765
3811
  const t = ae.fromBech32(e);
3766
3812
  if (t.version === 1 && t.data.length === 32)
3767
3813
  return "p2tr";
3768
3814
  if (t.version === 0 && t.data.length === 20)
3769
3815
  return "p2wpkh";
3770
- if (Qe(e))
3816
+ if (tt(e))
3771
3817
  return "p2wsh";
3772
3818
  throw new Error("Address type is not supported.");
3773
3819
  }
3774
- function Qe(e) {
3820
+ function tt(e) {
3775
3821
  return (e.startsWith("bc1") || e.startsWith("tb1")) && e.length === 62;
3776
3822
  }
3777
- function vt({
3823
+ function Et({
3778
3824
  btcAddress: e,
3779
3825
  amount: t,
3780
3826
  env: n,
3781
3827
  ...a
3782
3828
  }) {
3783
- const s = new D(a), r = C(s, n), o = Xe(e, n), p = K(t), u = r.methods.redeem(o, p);
3829
+ const s = new D(a), r = C(s, n), o = Qe(e, n), p = q(t), y = r.methods.redeem(o, p);
3784
3830
  return s.sendTransactionAsync(
3785
3831
  s.account,
3786
3832
  r.options.address,
3787
3833
  {
3788
- data: u.encodeABI(),
3834
+ data: y.encodeABI(),
3789
3835
  estimate: !0,
3790
3836
  estimateFee: !0,
3791
3837
  gasLimitMultiplier: k(s.chainId)
3792
3838
  }
3793
3839
  );
3794
3840
  }
3841
+ async function Dt({
3842
+ chainId: e,
3843
+ rpcUrl: t,
3844
+ vaultAddress: n
3845
+ }) {
3846
+ const a = B(e, t), s = new M({ chainId: e, rpcUrlConfig: a });
3847
+ try {
3848
+ return (await s.createContract(Fe, n).methods.getStakeAndBakeFee().call()).toString();
3849
+ } catch (r) {
3850
+ const o = T(r);
3851
+ throw new Error(o);
3852
+ }
3853
+ }
3795
3854
  export {
3796
- Le as BasculeDepositStatus,
3855
+ Ge as BasculeDepositStatus,
3797
3856
  Ae as ENotarizationStatus,
3798
3857
  ve as ESessionState,
3799
3858
  i as OChainId,
@@ -3801,38 +3860,40 @@ export {
3801
3860
  le as SANCTIONED_ADDRESS,
3802
3861
  F as SATOSHI_SCALE,
3803
3862
  X as STAKE_AND_BAKE_VAULTS,
3804
- wt as SUPPORTED_STAKE_AND_BAKE_CHAINS,
3805
- mt as approveLBTC,
3806
- ct as claimLBTC,
3807
- Z as fromSatoshi,
3808
- it as generateDepositBtcAddress,
3809
- A as getApiConfig,
3810
- bt as getBasculeDepositStatus,
3863
+ Ct as SUPPORTED_STAKE_AND_BAKE_CHAINS,
3864
+ ft as approveLBTC,
3865
+ Tt as claimLBTC,
3866
+ K as fromSatoshi,
3867
+ ot as generateDepositBtcAddress,
3868
+ v as getApiConfig,
3869
+ ht as getBasculeDepositStatus,
3811
3870
  re as getBaseNetworkByEnv,
3812
3871
  ie as getBscNetworkByEnv,
3813
3872
  we as getChainIdByName,
3814
3873
  O as getChainNameById,
3815
- rt as getDepositBtcAddress,
3874
+ pt as getDepositBtcAddress,
3816
3875
  he as getDepositBtcAddresses,
3817
- ot as getDepositsByAddress,
3876
+ ut as getDepositsByAddress,
3818
3877
  se as getEthNetworkByEnv,
3819
- pt as getLBTCExchangeRate,
3820
- ft as getLBTCMintingFee,
3821
- Tt as getLBTCTotalSupply,
3822
- q as getLbtcAddressConfig,
3823
- ut as getNetworkFeeSignature,
3824
- Ge as getPermitNonce,
3825
- ze as getStakeAndBakeSpenderContract,
3826
- qe as getStakeAndBakeTypedData,
3827
- Ke as getStakeAndBakeVaults,
3828
- yt as getUserStakeAndBakeSignature,
3878
+ yt as getLBTCExchangeRate,
3879
+ gt as getLBTCMintingFee,
3880
+ wt as getLBTCTotalSupply,
3881
+ j as getLbtcAddressConfig,
3882
+ dt as getNetworkFeeSignature,
3883
+ He as getPermitNonce,
3884
+ Dt as getStakeAndBakeFee,
3885
+ je as getStakeAndBakeSpenderContract,
3886
+ Je as getStakeAndBakeTypedData,
3887
+ ze as getStakeAndBakeVaults,
3888
+ lt as getUserStakeAndBakeSignature,
3829
3889
  z as isValidChain,
3830
- ht as signLbtcDestionationAddr,
3831
- gt as signNetworkFee,
3832
- At as signStakeAndBake,
3833
- dt as storeNetworkFeeSignature,
3834
- lt as storeStakeAndBakeSignature,
3835
- K as toSatoshi,
3836
- vt as unstakeLBTC
3890
+ bt as setReferral,
3891
+ At as signLbtcDestionationAddr,
3892
+ vt as signNetworkFee,
3893
+ St as signStakeAndBake,
3894
+ ct as storeNetworkFeeSignature,
3895
+ mt as storeStakeAndBakeSignature,
3896
+ q as toSatoshi,
3897
+ Et as unstakeLBTC
3837
3898
  };
3838
3899
  //# sourceMappingURL=index.js.map