@lombard.finance/sdk 2.0.11 → 2.0.12

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,9 +1,9 @@
1
1
  var me = Object.defineProperty;
2
2
  var be = (e, t, n) => t in e ? me(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var I = (e, t, n) => (be(e, typeof t != "symbol" ? t + "" : t, n), n);
4
- import v from "axios";
4
+ import E from "axios";
5
5
  import _ from "bignumber.js";
6
- import pe, { Web3 as se, utils as E } from "web3";
6
+ import pe, { Web3 as se, utils as R } from "web3";
7
7
  const g = {
8
8
  prod: "prod",
9
9
  testnet: "testnet",
@@ -25,7 +25,7 @@ const g = {
25
25
  baseApiUrl: "https://gastald-testnet.prod.lombard.finance"
26
26
  }, Ee = {
27
27
  baseApiUrl: "https://mainnet.prod.lombard.finance"
28
- }, A = (e = K) => {
28
+ }, v = (e = K) => {
29
29
  switch (e) {
30
30
  case g.prod:
31
31
  return Ee;
@@ -35,7 +35,7 @@ const g = {
35
35
  return ge;
36
36
  }
37
37
  };
38
- function R(e) {
38
+ function A(e) {
39
39
  return typeof e == "string" ? e : ((n) => {
40
40
  var a;
41
41
  return ((a = n == null ? void 0 : n.data) == null ? void 0 : a.message) && typeof n.data.message == "string";
@@ -84,7 +84,7 @@ async function Ot({
84
84
  partnerId: o,
85
85
  captchaToken: p
86
86
  }) {
87
- const { baseApiUrl: u } = A(s), f = X(t), l = {
87
+ const { baseApiUrl: u } = v(s), f = X(t), c = {
88
88
  to_address: e,
89
89
  to_address_signature: n,
90
90
  to_chain: f,
@@ -95,14 +95,14 @@ async function Ot({
95
95
  eip_712_data: a
96
96
  };
97
97
  try {
98
- const { data: d } = await v.post(
98
+ const { data: d } = await E.post(
99
99
  Ie,
100
- l,
100
+ c,
101
101
  { baseURL: u }
102
102
  );
103
103
  return d.address;
104
104
  } catch (d) {
105
- const h = R(d);
105
+ const h = A(d);
106
106
  if (_e(h))
107
107
  return Re;
108
108
  throw new Error(h);
@@ -140,14 +140,14 @@ async function xe({
140
140
  env: n,
141
141
  partnerId: a
142
142
  }) {
143
- const { baseApiUrl: s } = A(n), r = X(t), o = {
143
+ const { baseApiUrl: s } = v(n), r = X(t), o = {
144
144
  to_address: e,
145
145
  to_blockchain: r,
146
146
  limit: 1,
147
147
  offset: 0,
148
148
  asc: !1,
149
149
  referralId: a
150
- }, { data: p } = await v.get(Ce, {
150
+ }, { data: p } = await E.get(Ce, {
151
151
  baseURL: s,
152
152
  params: o
153
153
  });
@@ -177,7 +177,7 @@ async function Bt({
177
177
  address: e,
178
178
  env: t
179
179
  }) {
180
- const { baseApiUrl: n } = A(t), { data: a } = await v.get(
180
+ const { baseApiUrl: n } = v(t), { data: a } = await E.get(
181
181
  `api/v1/address/outputs-v2/${e}`,
182
182
  { baseURL: n }
183
183
  );
@@ -209,7 +209,7 @@ async function Lt({
209
209
  chainId: t = i.ethereum,
210
210
  amount: n = 1
211
211
  }) {
212
- const { baseApiUrl: a } = A(e), s = X(t), { data: r } = await v.get(
212
+ const { baseApiUrl: a } = v(e), s = X(t), { data: r } = await E.get(
213
213
  `api/v1/exchange/rate/${s}`,
214
214
  { baseURL: a, params: { amount: n } }
215
215
  ), o = new _(Fe).multipliedBy(Y).toFixed();
@@ -220,9 +220,9 @@ async function kt({
220
220
  chainId: t,
221
221
  env: n
222
222
  }) {
223
- const { baseApiUrl: a } = A(n);
223
+ const { baseApiUrl: a } = v(n);
224
224
  try {
225
- const { data: s } = await v.get(
225
+ const { data: s } = await E.get(
226
226
  `${a}/api/v1/claimer/get-user-signature`,
227
227
  {
228
228
  params: {
@@ -237,19 +237,43 @@ async function kt({
237
237
  isDelayed: s == null ? void 0 : s.is_delayed
238
238
  };
239
239
  } catch (s) {
240
- const r = R(s);
240
+ const r = A(s);
241
241
  throw new Error(r);
242
242
  }
243
243
  }
244
244
  async function Gt({
245
+ userDestinationAddress: e,
246
+ chainId: t,
247
+ env: n
248
+ }) {
249
+ const { baseApiUrl: a } = v(n);
250
+ try {
251
+ const { data: s } = await E.get(
252
+ `${a}/api/v1/claimer/get-user-stake-and-bake-signature`,
253
+ {
254
+ params: {
255
+ userDestinationAddress: e,
256
+ chainId: t.toString()
257
+ }
258
+ }
259
+ );
260
+ return s;
261
+ } catch (s) {
262
+ const r = A(s);
263
+ throw new Error(
264
+ `Failed to get user stake and bake signature: ${r}`
265
+ );
266
+ }
267
+ }
268
+ async function Wt({
245
269
  signature: e,
246
270
  typedData: t,
247
271
  address: n,
248
272
  env: a
249
273
  }) {
250
- const { baseApiUrl: s } = A(a);
274
+ const { baseApiUrl: s } = v(a);
251
275
  try {
252
- const { data: r } = await v.post(
276
+ const { data: r } = await E.post(
253
277
  `${s}/api/v1/claimer/save-user-signature`,
254
278
  null,
255
279
  {
@@ -262,18 +286,18 @@ async function Gt({
262
286
  );
263
287
  return r.status;
264
288
  } catch (r) {
265
- const o = R(r);
289
+ const o = A(r);
266
290
  throw new Error(o);
267
291
  }
268
292
  }
269
- async function Wt({
293
+ async function Vt({
270
294
  signature: e,
271
295
  typedData: t,
272
296
  env: n
273
297
  }) {
274
- const { baseApiUrl: a } = A(n);
298
+ const { baseApiUrl: a } = v(n);
275
299
  try {
276
- const { data: s } = await v.post(
300
+ const { data: s } = await E.post(
277
301
  `${a}/api/v1/claimer/save-stake-and-bake-signature`,
278
302
  null,
279
303
  {
@@ -285,7 +309,7 @@ async function Wt({
285
309
  );
286
310
  return s.status;
287
311
  } catch (s) {
288
- const r = R(s);
312
+ const r = A(s);
289
313
  throw new Error(r);
290
314
  }
291
315
  }
@@ -421,46 +445,46 @@ class C extends Q {
421
445
  const { chainId: r, web3: o } = this, p = this.getReadWeb3(), {
422
446
  data: u,
423
447
  estimate: f = !1,
424
- estimateFee: l = !1,
448
+ estimateFee: c = !1,
425
449
  extendedGasLimit: d,
426
450
  gasLimit: h = "0",
427
451
  value: x = "0",
428
- gasLimitMultiplier: ce = 1
452
+ gasLimitMultiplier: le = 1
429
453
  } = s;
430
454
  let { nonce: N } = s;
431
455
  N || (N = await p.eth.getTransactionCount(n)), console.log(`Nonce: ${N}`);
432
- const c = {
456
+ const l = {
433
457
  from: n,
434
458
  to: a,
435
- value: E.numberToHex(x),
459
+ value: R.numberToHex(x),
436
460
  data: u,
437
461
  nonce: N,
438
- chainId: E.numberToHex(r)
462
+ chainId: R.numberToHex(r)
439
463
  };
440
464
  if (f)
441
465
  try {
442
- const w = await p.eth.estimateGas(c), M = Math.round(
443
- Number(w) * ce
466
+ const w = await p.eth.estimateGas(l), M = Math.round(
467
+ Number(w) * le
444
468
  );
445
- d ? c.gas = E.numberToHex(M + d) : c.gas = E.numberToHex(M);
469
+ d ? l.gas = R.numberToHex(M + d) : l.gas = R.numberToHex(M);
446
470
  } catch (w) {
447
471
  throw new Error(
448
472
  w.message ?? "Failed to estimate gas limit for transaction."
449
473
  );
450
474
  }
451
475
  else
452
- c.gas = E.numberToHex(h);
453
- const { maxFeePerGas: ee, maxPriorityFeePerGas: te } = l ? await this.getMaxFees().catch(() => s) : s;
454
- if (te !== void 0 && (c.maxPriorityFeePerGas = E.numberToHex(te)), ee !== void 0 && (c.maxFeePerGas = E.numberToHex(ee)), !c.maxFeePerGas && !c.maxPriorityFeePerGas) {
476
+ l.gas = R.numberToHex(h);
477
+ const { maxFeePerGas: ee, maxPriorityFeePerGas: te } = c ? await this.getMaxFees().catch(() => s) : s;
478
+ if (te !== void 0 && (l.maxPriorityFeePerGas = R.numberToHex(te)), ee !== void 0 && (l.maxFeePerGas = R.numberToHex(ee)), !l.maxFeePerGas && !l.maxPriorityFeePerGas) {
455
479
  const w = await this.getSafeGasPriceWei();
456
- c.gasPrice = w.toString(10);
480
+ l.gasPrice = w.toString(10);
457
481
  }
458
- if (!c.maxFeePerGas && !c.maxPriorityFeePerGas) {
482
+ if (!l.maxFeePerGas && !l.maxPriorityFeePerGas) {
459
483
  const w = await this.getSafeGasPriceWei();
460
- c.gasPrice = w.toString(10);
484
+ l.gasPrice = w.toString(10);
461
485
  }
462
- return console.log("Sending transaction via Web3: ", c), new Promise((w, M) => {
463
- const ne = o.eth.sendTransaction(c);
486
+ return console.log("Sending transaction via Web3: ", l), new Promise((w, M) => {
487
+ const ne = o.eth.sendTransaction(l);
464
488
  ne.once("transactionHash", async (ae) => {
465
489
  console.log(`Just signed transaction has is: ${ae}`), w({
466
490
  receiptPromise: ne,
@@ -510,7 +534,7 @@ const We = {
510
534
  [i.berachainBartioTestnet]: "0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",
511
535
  [i.corn]: y,
512
536
  [i.swell]: y
513
- }, He = {
537
+ }, $e = {
514
538
  [i.ethereum]: "0x8236a87084f8b84306f72007f36f2618a5634494",
515
539
  [i.holesky]: y,
516
540
  [i.sepolia]: y,
@@ -522,10 +546,10 @@ const We = {
522
546
  [i.corn]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
523
547
  [i.swell]: "0xecAc9C5F704e954931349Da37F60E39f515c11c1"
524
548
  };
525
- function $e(e = K) {
549
+ function He(e = K) {
526
550
  switch (e) {
527
551
  case g.prod:
528
- return He;
552
+ return $e;
529
553
  case g.testnet:
530
554
  return Ve;
531
555
  default:
@@ -3372,7 +3396,7 @@ function Ze(e) {
3372
3396
  }
3373
3397
  }
3374
3398
  function D(e, t) {
3375
- const n = $e(t), { chainId: a } = e;
3399
+ const n = He(t), { chainId: a } = e;
3376
3400
  if (!ue(a))
3377
3401
  throw new Error(`This chain ${a} is not supported`);
3378
3402
  const s = n[a];
@@ -3382,7 +3406,7 @@ function D(e, t) {
3382
3406
  return o.options.address || (o.options.address = s), o;
3383
3407
  }
3384
3408
  const ze = "insufficient funds", Ke = "Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.", ie = (e) => e.startsWith("0x") ? e : "0x" + e;
3385
- async function Vt({
3409
+ async function $t({
3386
3410
  data: e,
3387
3411
  proofSignature: t,
3388
3412
  env: n,
@@ -3403,11 +3427,11 @@ async function Vt({
3403
3427
  );
3404
3428
  } catch (p) {
3405
3429
  console.log("error", p);
3406
- const u = R(p);
3430
+ const u = A(p);
3407
3431
  throw u.includes(ze) ? new Error(Ke) : new Error(u);
3408
3432
  }
3409
3433
  }
3410
- const Xe = 208, Ye = 4001, Qe = 4100, et = 4200, tt = 4900, nt = 4901, O = -32700, U = -32600, F = -32601, B = -32602, L = -32603, k = -32e3, G = -32001, W = -32002, V = -32003, H = -32004, $ = -32005, J = -32006;
3434
+ const Xe = 208, Ye = 4001, Qe = 4100, et = 4200, tt = 4900, nt = 4901, O = -32700, U = -32600, F = -32601, B = -32602, L = -32603, k = -32e3, G = -32001, W = -32002, V = -32003, $ = -32004, H = -32005, J = -32006;
3411
3435
  class ye extends Error {
3412
3436
  constructor(t, n) {
3413
3437
  super(t), Array.isArray(n) ? this.cause = new Z(n) : this.cause = n, this.name = this.constructor.name, typeof Error.captureStackTrace == "function" ? Error.captureStackTrace(new.target.constructor) : this.stack = new Error().stack;
@@ -3485,11 +3509,11 @@ const at = "An Rpc error has occured with a code of *code*", m = {
3485
3509
  message: "Transaction rejected",
3486
3510
  description: "Transaction creation failed"
3487
3511
  },
3488
- [H]: {
3512
+ [$]: {
3489
3513
  message: "Method not supported",
3490
3514
  description: "Method is not implemented"
3491
3515
  },
3492
- [$]: {
3516
+ [H]: {
3493
3517
  message: "Limit exceeded",
3494
3518
  description: "Request exceeds defined limit"
3495
3519
  },
@@ -3642,7 +3666,7 @@ class ut extends b {
3642
3666
  }
3643
3667
  class yt extends b {
3644
3668
  constructor(t) {
3645
- super(t, m[H].message), this.code = H;
3669
+ super(t, m[$].message), this.code = $;
3646
3670
  }
3647
3671
  }
3648
3672
  class dt extends b {
@@ -3650,12 +3674,12 @@ class dt extends b {
3650
3674
  super(t, m[W].message), this.code = W;
3651
3675
  }
3652
3676
  }
3653
- class lt extends b {
3677
+ class ct extends b {
3654
3678
  constructor(t) {
3655
3679
  super(t, m[G].message), this.code = G;
3656
3680
  }
3657
3681
  }
3658
- class ct extends b {
3682
+ class lt extends b {
3659
3683
  constructor(t) {
3660
3684
  super(t, m[J].message), this.code = J;
3661
3685
  }
@@ -3667,7 +3691,7 @@ class mt extends b {
3667
3691
  }
3668
3692
  class bt extends b {
3669
3693
  constructor(t) {
3670
- super(t, m[$].message), this.code = $;
3694
+ super(t, m[H].message), this.code = H;
3671
3695
  }
3672
3696
  }
3673
3697
  const T = /* @__PURE__ */ new Map();
@@ -3681,7 +3705,7 @@ T.set(F, {
3681
3705
  T.set(B, { error: ot });
3682
3706
  T.set(L, { error: pt });
3683
3707
  T.set(k, { error: ut });
3684
- T.set(H, {
3708
+ T.set($, {
3685
3709
  error: yt
3686
3710
  });
3687
3711
  T.set(W, {
@@ -3691,12 +3715,12 @@ T.set(V, {
3691
3715
  error: mt
3692
3716
  });
3693
3717
  T.set(G, {
3694
- error: lt
3718
+ error: ct
3695
3719
  });
3696
3720
  T.set(J, {
3697
- error: ct
3721
+ error: lt
3698
3722
  });
3699
- T.set($, { error: bt });
3723
+ T.set(H, { error: bt });
3700
3724
  const Tt = (e) => typeof e == "string" && /^((-)?0x[0-9a-f]+|(0x))$/i.test(e);
3701
3725
  var j;
3702
3726
  (function(e) {
@@ -3741,7 +3765,7 @@ async function Ht({
3741
3765
  const p = await o.methods.depositHistory(Buffer.from(e.replace(/^0x/, ""), "hex")).call();
3742
3766
  return Number(p);
3743
3767
  } catch (p) {
3744
- const u = R(p);
3768
+ const u = A(p);
3745
3769
  throw new Error(u);
3746
3770
  }
3747
3771
  }
@@ -3750,7 +3774,7 @@ const Et = [
3750
3774
  i.base,
3751
3775
  i.binanceSmartChain
3752
3776
  ], de = (e) => Et.includes(e) ? g.prod : g.stage;
3753
- function le(e, t) {
3777
+ function ce(e, t) {
3754
3778
  if (!ue(e))
3755
3779
  throw new Error(`This chain ${e} is not supported`);
3756
3780
  const n = t ? { [e]: t } : P;
@@ -3758,15 +3782,15 @@ function le(e, t) {
3758
3782
  throw new Error(`RPC URL for chainId ${e} not found`);
3759
3783
  return n;
3760
3784
  }
3761
- async function $t({
3785
+ async function Jt({
3762
3786
  chainId: e,
3763
3787
  bakeGasEstimate: t = 0,
3764
3788
  rpcUrl: n
3765
3789
  }) {
3766
- const a = le(e, n), s = new Q({ chainId: e, rpcUrlConfig: a }), r = de(e), p = await D(s, r).methods.getMintFee().call(), u = new _(z(p.toString(10)));
3790
+ const a = ce(e, n), s = new Q({ chainId: e, rpcUrlConfig: a }), r = de(e), p = await D(s, r).methods.getMintFee().call(), u = new _(z(p.toString(10)));
3767
3791
  return t ? u.plus(z(t)) : u;
3768
3792
  }
3769
- async function Jt(e) {
3793
+ async function jt(e) {
3770
3794
  const t = new C(e), n = `destination chain id is ${e.chainId}`;
3771
3795
  return t.signMessage(n);
3772
3796
  }
@@ -3806,7 +3830,7 @@ function At({
3806
3830
  };
3807
3831
  }
3808
3832
  const Rt = "Failed to obtain a valid signature. The response is undefined or invalid.", It = () => Math.floor(Date.now() / 1e3 + vt);
3809
- async function jt({
3833
+ async function qt({
3810
3834
  address: e,
3811
3835
  provider: t,
3812
3836
  fee: n,
@@ -3826,26 +3850,26 @@ async function jt({
3826
3850
  fee: n,
3827
3851
  expiry: r
3828
3852
  })
3829
- ), l = await ((h = (d = o.web3) == null ? void 0 : d.currentProvider) == null ? void 0 : h.request({
3853
+ ), c = await ((h = (d = o.web3) == null ? void 0 : d.currentProvider) == null ? void 0 : h.request({
3830
3854
  method: "eth_signTypedData_v4",
3831
3855
  params: [e, f]
3832
3856
  }));
3833
- if (typeof l == "string")
3834
- return { signature: l, typedData: f };
3835
- if (!(l != null && l.result))
3857
+ if (typeof c == "string")
3858
+ return { signature: c, typedData: f };
3859
+ if (!(c != null && c.result))
3836
3860
  throw new Error(Rt);
3837
- return { signature: l.result, typedData: f };
3861
+ return { signature: c.result, typedData: f };
3838
3862
  }
3839
3863
  async function St({
3840
3864
  owner: e,
3841
3865
  rpcUrl: t,
3842
3866
  chainId: n
3843
3867
  }) {
3844
- const a = le(n, t), s = new Q({ chainId: n, rpcUrlConfig: a }), r = de(n), o = D(s, r);
3868
+ const a = ce(n, t), s = new Q({ chainId: n, rpcUrlConfig: a }), r = de(n), o = D(s, r);
3845
3869
  try {
3846
3870
  return (await o.methods.nonces(e).call()).toString();
3847
3871
  } catch (p) {
3848
- const u = R(p);
3872
+ const u = A(p);
3849
3873
  throw new Error(u);
3850
3874
  }
3851
3875
  }
@@ -3908,7 +3932,7 @@ async function _t({
3908
3932
  };
3909
3933
  }
3910
3934
  const Ct = "Failed to obtain a valid signature. The response is undefined or invalid.";
3911
- async function qt({
3935
+ async function Zt({
3912
3936
  address: e,
3913
3937
  provider: t,
3914
3938
  chainId: n,
@@ -3931,22 +3955,22 @@ async function qt({
3931
3955
  value: a,
3932
3956
  rpcUrl: r,
3933
3957
  verifyingContract: p
3934
- }), l = JSON.stringify(f), d = await ((x = (h = u.web3) == null ? void 0 : h.currentProvider) == null ? void 0 : x.request({
3958
+ }), c = JSON.stringify(f), d = await ((x = (h = u.web3) == null ? void 0 : h.currentProvider) == null ? void 0 : x.request({
3935
3959
  method: "eth_signTypedData_v4",
3936
- params: [e, l]
3960
+ params: [e, c]
3937
3961
  }));
3938
3962
  if (typeof d == "string")
3939
- return { signature: d, typedData: l };
3963
+ return { signature: d, typedData: c };
3940
3964
  if (!(d != null && d.result))
3941
3965
  throw new Error(Ct);
3942
- return { signature: d.result, typedData: l };
3966
+ return { signature: d.result, typedData: c };
3943
3967
  }
3944
3968
  const Dt = {
3945
3969
  [i.holesky]: {
3946
3970
  SPENDER: "0x52BD640617eeD47A00dA0da93351092D49208d1d",
3947
3971
  VERIFYING_CONTRACT: "0xED7bfd5C1790576105Af4649817f6d35A75CD818"
3948
3972
  }
3949
- }, Zt = (e) => {
3973
+ }, zt = (e) => {
3950
3974
  var n;
3951
3975
  const t = (n = Dt[e]) == null ? void 0 : n.SPENDER;
3952
3976
  if (!t)
@@ -3961,10 +3985,10 @@ export {
3961
3985
  g as OEnv,
3962
3986
  Re as SANCTIONED_ADDRESS,
3963
3987
  Y as SATOSHI_SCALE,
3964
- Vt as claimLBTC,
3988
+ $t as claimLBTC,
3965
3989
  z as fromSatoshi,
3966
3990
  Ot as generateDepositBtcAddress,
3967
- A as getApiConfig,
3991
+ v as getApiConfig,
3968
3992
  Ht as getBasculeDepositStatus,
3969
3993
  he as getBaseNetworkByEnv,
3970
3994
  fe as getBscNetworkByEnv,
@@ -3975,17 +3999,18 @@ export {
3975
3999
  Bt as getDepositsByAddress,
3976
4000
  Te as getEthNetworkByEnv,
3977
4001
  Lt as getLBTCExchangeRate,
3978
- $t as getLBTCMintingFee,
3979
- $e as getLbtcAddressConfig,
4002
+ Jt as getLBTCMintingFee,
4003
+ He as getLbtcAddressConfig,
3980
4004
  kt as getNetworkFeeSignature,
3981
- Zt as getStakeAndBakeSpenderAddress,
4005
+ zt as getStakeAndBakeSpenderAddress,
3982
4006
  _t as getStakeAndBakeTypedData,
4007
+ Gt as getUserStakeAndBakeSignature,
3983
4008
  ue as isValidChain,
3984
- Jt as signLbtcDestionationAddr,
3985
- jt as signNetworkFee,
3986
- qt as signStakeAndBake,
3987
- Gt as storeNetworkFeeSignature,
3988
- Wt as storeStakeAndBakeSignature,
4009
+ jt as signLbtcDestionationAddr,
4010
+ qt as signNetworkFee,
4011
+ Zt as signStakeAndBake,
4012
+ Wt as storeNetworkFeeSignature,
4013
+ Vt as storeStakeAndBakeSignature,
3989
4014
  Ft as toSatoshi
3990
4015
  };
3991
4016
  //# sourceMappingURL=index.js.map