@lombard.finance/sdk 5.0.0 → 5.0.2

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/btc.cjs +1 -1
  3. package/dist/btc.js +2 -2
  4. package/dist/chains/evm/actions/withdraw/EvmWithdraw.d.ts +27 -3
  5. package/dist/chains/evm/actions/withdraw/EvmWithdraw.d.ts.map +1 -1
  6. package/dist/chunks/{BtcActions-DJJmmyzi.cjs → BtcActions-B9KwzjIG.cjs} +2 -2
  7. package/dist/chunks/{BtcActions-DJJmmyzi.cjs.map → BtcActions-B9KwzjIG.cjs.map} +1 -1
  8. package/dist/chunks/{BtcActions-CFGiDxtv.js → BtcActions-CJY0V8JC.js} +2 -2
  9. package/dist/chunks/{BtcActions-CFGiDxtv.js.map → BtcActions-CJY0V8JC.js.map} +1 -1
  10. package/dist/chunks/{EvmActions-CUKBeiUw.js → EvmActions-BGlhbADC.js} +324 -270
  11. package/dist/chunks/{EvmActions-CUKBeiUw.js.map → EvmActions-BGlhbADC.js.map} +1 -1
  12. package/dist/chunks/{EvmActions-CxipDb7X.cjs → EvmActions-DBAcQeMr.cjs} +7 -7
  13. package/dist/chunks/{EvmActions-CxipDb7X.cjs.map → EvmActions-DBAcQeMr.cjs.map} +1 -1
  14. package/dist/chunks/{events-B9b3YdgM.cjs → events-DBUF2B7z.cjs} +2 -2
  15. package/dist/chunks/{events-B9b3YdgM.cjs.map → events-DBUF2B7z.cjs.map} +1 -1
  16. package/dist/chunks/{events-DU2wYlt_.js → events-od93kR_o.js} +4 -4
  17. package/dist/chunks/{events-DU2wYlt_.js.map → events-od93kR_o.js.map} +1 -1
  18. package/dist/chunks/{statusConstants-B-7VEYgO.cjs → statusConstants-CP33VFvI.cjs} +2 -2
  19. package/dist/chunks/{statusConstants-B-7VEYgO.cjs.map → statusConstants-CP33VFvI.cjs.map} +1 -1
  20. package/dist/chunks/{statusConstants-C3JHNUTC.js → statusConstants-sPFaTvG2.js} +2 -2
  21. package/dist/chunks/{statusConstants-C3JHNUTC.js.map → statusConstants-sPFaTvG2.js.map} +1 -1
  22. package/dist/chunks/{unwrapBtceToLbtcv-Dg-yUGpg.cjs → unwrapBtceToLbtcv-BlRUepkS.cjs} +2 -2
  23. package/dist/chunks/{unwrapBtceToLbtcv-Dg-yUGpg.cjs.map → unwrapBtceToLbtcv-BlRUepkS.cjs.map} +1 -1
  24. package/dist/chunks/{unwrapBtceToLbtcv-C4OxoVVU.js → unwrapBtceToLbtcv-Cu9KedO1.js} +3 -3
  25. package/dist/chunks/{unwrapBtceToLbtcv-C4OxoVVU.js.map → unwrapBtceToLbtcv-Cu9KedO1.js.map} +1 -1
  26. package/dist/chunks/{withdrawEarn-CTtVruit.cjs → withdrawEarn-CVQYjOoY.cjs} +3 -3
  27. package/dist/chunks/{withdrawEarn-CTtVruit.cjs.map → withdrawEarn-CVQYjOoY.cjs.map} +1 -1
  28. package/dist/chunks/{withdrawEarn-QFaMhs0t.js → withdrawEarn-D835YnBD.js} +36 -36
  29. package/dist/chunks/{withdrawEarn-QFaMhs0t.js.map → withdrawEarn-D835YnBD.js.map} +1 -1
  30. package/dist/contract-functions/previewWithdrawEarn/previewWithdrawEarn.d.ts.map +1 -1
  31. package/dist/contract-functions/withdrawEarn/withdrawEarn.d.ts +8 -4
  32. package/dist/contract-functions/withdrawEarn/withdrawEarn.d.ts.map +1 -1
  33. package/dist/contracts.cjs +1 -1
  34. package/dist/contracts.js +2 -2
  35. package/dist/core.cjs +1 -1
  36. package/dist/core.js +5 -5
  37. package/dist/evm.cjs +1 -1
  38. package/dist/evm.js +3 -3
  39. package/dist/index.cjs +1 -1
  40. package/dist/index.js +6 -6
  41. package/package.json +1 -1
@@ -1,18 +1,18 @@
1
1
  var dt = Object.defineProperty;
2
2
  var pt = (r, a, t) => a in r ? dt(r, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[a] = t;
3
- var p = (r, a, t) => pt(r, typeof a != "symbol" ? a + "" : a, t);
3
+ var m = (r, a, t) => pt(r, typeof a != "symbol" ? a + "" : a, t);
4
4
  import D from "bignumber.js";
5
- import { getMintingFee as at, signNetworkFee as it, getStakeAndBakeFee as mt, signStakeAndBake as lt, signLbtcDestinationAddr as vt, waitForTransactionReceipt as U, depositEarn as Et, claimLBTC as Ct, redeemToken as nt, getTokenAllowance as _t, approveToken as gt, depositToken as At, cancelWithdrawInternal as It, withdrawEarn as ft, queueWithdrawInternal as wt } from "./withdrawEarn-QFaMhs0t.js";
6
- import { Token as v, makeWalletClient as z, CHAIN_ID_TO_VIEM_CHAIN_MAP as b, AddressKind as Dt, ChainId as et } from "./token-addresses-DVnRPyu4.js";
7
- import { makePublicClient as x, getTokenInfo as q, toBaseDenomination as y, fromBaseDenomination as B, getErrorMessage as Pt, getTokenContractInfo as W } from "./tokens-Btl3GXbc.js";
8
- import { Chain as I, BaseAction as S, EvmOperationStatus as s, validatePrepareParams as L, LombardError as h, parseChainIdentifier as A, StepStatus as i, objectType as N, evmAmountSchema as O, stringType as Tt, evmAddressSchema as rt, getEvmAssetChains as P, bitcoinAddressSchema as ot, getEvmChainsWithAllAssets as ct, WithdrawErrorCode as V, createEvmCoreContext as St } from "./statusConstants-C3JHNUTC.js";
5
+ import { getMintingFee as at, signNetworkFee as it, getStakeAndBakeFee as mt, signStakeAndBake as lt, signLbtcDestinationAddr as vt, waitForTransactionReceipt as F, depositEarn as Et, claimLBTC as Ct, redeemToken as nt, getTokenAllowance as _t, approveToken as gt, depositToken as wt, cancelWithdrawInternal as At, withdrawEarn as It, queueWithdrawInternal as ft } from "./withdrawEarn-D835YnBD.js";
6
+ import { Token as E, makeWalletClient as z, CHAIN_ID_TO_VIEM_CHAIN_MAP as M, AddressKind as Dt, ChainId as et } from "./token-addresses-DVnRPyu4.js";
7
+ import { makePublicClient as N, getTokenInfo as U, toBaseDenomination as q, fromBaseDenomination as y, getErrorMessage as Tt, getTokenContractInfo as W } from "./tokens-Btl3GXbc.js";
8
+ import { Chain as I, BaseAction as x, EvmOperationStatus as s, validatePrepareParams as O, LombardError as h, parseChainIdentifier as w, StepStatus as i, objectType as B, evmAmountSchema as b, stringType as Pt, evmAddressSchema as rt, getEvmAssetChains as T, bitcoinAddressSchema as ot, getEvmChainsWithAllAssets as ct, WithdrawErrorCode as H, createEvmCoreContext as St } from "./statusConstants-sPFaTvG2.js";
9
9
  import { getNetworkFeeSignature as xt, storeNetworkFeeSignature as Lt } from "./storeNetworkFeeSignature-CY_Z-Wtn.js";
10
10
  import { requiresAutoMintFee as Nt } from "./fee-requirements-CCNsxAvJ.js";
11
- import { DefiProtocol as T, AssetId as l } from "./defi-registry-DULXbu3D.js";
11
+ import { DefiProtocol as S, AssetId as l } from "./defi-registry-DULXbu3D.js";
12
12
  import { r as o } from "./index-CfcQ_g3t.js";
13
13
  import { erc20Abi as st } from "viem";
14
14
  import { toBigInt as Z } from "./numbers-CclN2Ohk.js";
15
- import { isEarnChain as j, EARN_VAULT as M, isBtceVaultChain as G, BTCE_VAULT as $ } from "./config-wnjPtnjd.js";
15
+ import { isEarnChain as j, EARN_VAULT as Y, isBtceVaultChain as k, BTCE_VAULT as P } from "./config-wnjPtnjd.js";
16
16
  class Ot {
17
17
  constructor(a) {
18
18
  this.env = a;
@@ -24,7 +24,7 @@ class Ot {
24
24
  */
25
25
  async getMintingFee(a, t) {
26
26
  return (await at({
27
- token: t || v.LBTC,
27
+ token: t || E.LBTC,
28
28
  chainId: a,
29
29
  env: this.env
30
30
  })).toString();
@@ -40,7 +40,7 @@ class Ot {
40
40
  provider: a.provider,
41
41
  env: this.env,
42
42
  // Pass token for signing - defaults to LBTC for backwards compatibility
43
- token: a.token ?? v.LBTC
43
+ token: a.token ?? E.LBTC
44
44
  });
45
45
  return {
46
46
  signature: t.signature,
@@ -85,7 +85,7 @@ class Ot {
85
85
  }) };
86
86
  }
87
87
  }
88
- function Pe() {
88
+ function Te() {
89
89
  return {
90
90
  id: "evm",
91
91
  chain: "evm",
@@ -100,127 +100,127 @@ const Bt = {
100
100
  {
101
101
  asset: l.LBTC,
102
102
  sourceChains: [I.ETHEREUM],
103
- protocols: [T.Veda],
103
+ protocols: [S.Veda],
104
104
  envs: [o.prod]
105
105
  },
106
106
  // Veda - Base
107
107
  {
108
108
  asset: l.LBTC,
109
109
  sourceChains: [I.BASE],
110
- protocols: [T.Veda],
110
+ protocols: [S.Veda],
111
111
  envs: [o.prod]
112
112
  },
113
113
  // Veda - BSC
114
114
  {
115
115
  asset: l.LBTC,
116
116
  sourceChains: [I.BSC],
117
- protocols: [T.Veda],
117
+ protocols: [S.Veda],
118
118
  envs: [o.prod]
119
119
  },
120
120
  // Veda - Corn
121
121
  {
122
122
  asset: l.LBTC,
123
123
  sourceChains: [I.CORN],
124
- protocols: [T.Veda],
124
+ protocols: [S.Veda],
125
125
  envs: [o.prod]
126
126
  },
127
127
  // Silo - Avalanche
128
128
  {
129
129
  asset: l.LBTC,
130
130
  sourceChains: [I.AVALANCHE],
131
- protocols: [T.Silo],
131
+ protocols: [S.Silo],
132
132
  envs: [o.prod]
133
133
  }
134
134
  ]
135
135
  };
136
- async function Rt({
136
+ async function bt({
137
137
  amount: r,
138
138
  approve: a = !0,
139
- token: t = v.LBTC,
139
+ token: t = E.LBTC,
140
140
  account: e,
141
141
  chainId: n,
142
- provider: m,
142
+ provider: d,
143
143
  rpcUrl: u,
144
- env: d
144
+ env: p
145
145
  }) {
146
- const c = M;
146
+ const c = Y;
147
147
  if (!j(n))
148
148
  throw new Error(
149
149
  `Unsupported chain id: ${n}. Please switch to one of the supported chains: ${c.chains.join(", ")}`
150
150
  );
151
- const E = x({ chainId: n, rpcUrl: u }), _ = z({ provider: m, chainId: n }), C = await q(t, n, d, u);
152
- if (!C)
151
+ const _ = N({ chainId: n, rpcUrl: u }), g = z({ provider: d, chainId: n }), v = await U(t, n, p, u);
152
+ if (!v)
153
153
  throw new Error(`Unknown deposit token: ${t}`);
154
- const g = D(r), w = Z(
155
- y(g, C.decimals)
156
- ), H = await E.readContract({
157
- address: C.address,
158
- abi: C.abi,
154
+ const C = D(r), A = Z(
155
+ q(C, v.decimals)
156
+ ), R = await _.readContract({
157
+ address: v.address,
158
+ abi: v.abi,
159
159
  functionName: "allowance",
160
160
  args: [e, c.vaultContract.address]
161
- }), R = B(
162
- String(H),
163
- C.decimals
164
- ), k = await E.readContract({
165
- address: C.address,
166
- abi: C.abi,
161
+ }), L = y(
162
+ String(R),
163
+ v.decimals
164
+ ), V = await _.readContract({
165
+ address: v.address,
166
+ abi: v.abi,
167
167
  functionName: "balanceOf",
168
168
  args: [e]
169
- }), X = B(
170
- String(k),
171
- C.decimals
169
+ }), X = y(
170
+ String(V),
171
+ v.decimals
172
172
  );
173
- if (g.isGreaterThan(X))
173
+ if (C.isGreaterThan(X))
174
174
  throw new Error(
175
175
  `The deposit amount exceeds the account's balance.
176
- Deposit amount: ${g.toFixed()}
176
+ Deposit amount: ${C.toFixed()}
177
177
  Balance: ${X.toFixed()}`
178
178
  );
179
- if (g.isGreaterThan(R)) {
179
+ if (C.isGreaterThan(L)) {
180
180
  const tt = `The deposit amount exceeds allowance.
181
- Deposit amount: ${g.toFixed()}
182
- Allowance: ${R.toFixed()}`;
181
+ Deposit amount: ${C.toFixed()}
182
+ Allowance: ${L.toFixed()}`;
183
183
  if (!a)
184
184
  throw new Error(tt);
185
185
  console.info(tt);
186
186
  try {
187
- console.info(`Trying to approve ${w}`);
188
- const { request: F } = await E.simulateContract({
187
+ console.info(`Trying to approve ${A}`);
188
+ const { request: $ } = await _.simulateContract({
189
189
  account: e,
190
- chain: b[n],
191
- address: C.address,
192
- abi: C.abi,
190
+ chain: M[n],
191
+ address: v.address,
192
+ abi: v.abi,
193
193
  functionName: "approve",
194
- args: [c.vaultContract.address, w]
195
- }), Y = await _.writeContract(F);
196
- console.info(`Approve tx hash: ${Y}`), console.info(`Approved ${w} for ${c.vaultContract.address}`);
197
- } catch (F) {
198
- const Y = Pt(F);
194
+ args: [c.vaultContract.address, A]
195
+ }), G = await g.writeContract($);
196
+ console.info(`Approve tx hash: ${G}`), console.info(`Approved ${A} for ${c.vaultContract.address}`);
197
+ } catch ($) {
198
+ const G = Tt($);
199
199
  throw new Error(
200
- `Could not approve ${w} for ${c.vaultContract.address}.
201
- Reason: ${Y}`
200
+ `Could not approve ${A} for ${c.vaultContract.address}.
201
+ Reason: ${G}`
202
202
  );
203
203
  }
204
204
  }
205
- const { request: ut } = await E.simulateContract({
205
+ const { request: ut } = await _.simulateContract({
206
206
  account: e,
207
- chain: b[n],
207
+ chain: M[n],
208
208
  address: c.tellerContracts[n].address,
209
209
  abi: c.tellerContracts[n].abi,
210
210
  functionName: "deposit",
211
- args: [C.address, w, 0n]
211
+ args: [v.address, A, 0n]
212
212
  });
213
- return await _.writeContract(ut);
213
+ return await g.writeContract(ut);
214
214
  }
215
- class bt extends S {
215
+ class Rt extends x {
216
216
  constructor(t, e) {
217
217
  super(s.IDLE);
218
- p(this, "_amount");
219
- p(this, "_protocol");
220
- p(this, "_needsApproval", !1);
221
- p(this, "_txHash");
222
- p(this, "_account");
223
- p(this, "_chainId");
218
+ m(this, "_amount");
219
+ m(this, "_protocol");
220
+ m(this, "_needsApproval", !1);
221
+ m(this, "_txHash");
222
+ m(this, "_account");
223
+ m(this, "_chainId");
224
224
  this.ctx = t, this.params = e;
225
225
  }
226
226
  get amount() {
@@ -240,7 +240,7 @@ class bt extends S {
240
240
  * Veda protocol on a chain that has the BTCe contract deployed.
241
241
  */
242
242
  isVedaBtcePath() {
243
- return this._protocol === T.Veda && this._chainId !== void 0 && G(this._chainId);
243
+ return this._protocol === S.Veda && this._chainId !== void 0 && k(this._chainId);
244
244
  }
245
245
  /**
246
246
  * Returns the ERC-20 spender address for LBTC approval:
@@ -248,11 +248,11 @@ class bt extends S {
248
248
  * - LBTCv BoringVault address for all other cases
249
249
  */
250
250
  getSpenderAddress() {
251
- return this.isVedaBtcePath() ? $.contracts[this._chainId] : M.vaultContract.address;
251
+ return this.isVedaBtcePath() ? P.contracts[this._chainId] : Y.vaultContract.address;
252
252
  }
253
253
  async prepare(t) {
254
254
  return this.assertStatus(s.IDLE, "prepare"), this.act(async () => {
255
- const e = L(this.prepareSchema, t);
255
+ const e = O(this.prepareSchema, t);
256
256
  this._amount = e.amount, this._protocol = t.protocol, this.validateProtocol(t.protocol);
257
257
  const n = await this.ctx.getProvider("evm");
258
258
  if (!n)
@@ -262,24 +262,24 @@ class bt extends S {
262
262
  }))[0];
263
263
  if (!u)
264
264
  throw h.providerMissing(this.params.sourceChain, "evm");
265
- this._account = u, this._chainId = A(this.params.sourceChain);
266
- const d = await q(
267
- v.LBTC,
265
+ this._account = u, this._chainId = w(this.params.sourceChain);
266
+ const p = await U(
267
+ E.LBTC,
268
268
  this._chainId,
269
269
  this.ctx.env
270
270
  );
271
- if (!d)
271
+ if (!p)
272
272
  throw h.invalidParameter(
273
273
  "token",
274
274
  "Could not get LBTC token info"
275
275
  );
276
- const c = this.getSpenderAddress(), _ = await x({ chainId: this._chainId }).readContract({
277
- address: d.address,
276
+ const c = this.getSpenderAddress(), g = await N({ chainId: this._chainId }).readContract({
277
+ address: p.address,
278
278
  abi: st,
279
279
  functionName: "allowance",
280
280
  args: [u, c]
281
- }), C = new D(e.amount), g = y(C, d.decimals), w = new D(String(_));
282
- this._needsApproval = g.isGreaterThan(w), this._needsApproval ? (this.emitProgress({
281
+ }), v = new D(e.amount), C = q(v, p.decimals), A = new D(String(g));
282
+ this._needsApproval = C.isGreaterThan(A), this._needsApproval ? (this.emitProgress({
283
283
  status: s.NEEDS_APPROVAL,
284
284
  steps: { approval: i.PENDING, deploying: i.IDLE }
285
285
  }), this.updateStatus(s.NEEDS_APPROVAL)) : (this.emitProgress({
@@ -298,8 +298,8 @@ class bt extends S {
298
298
  const t = await this.ctx.getProvider("evm");
299
299
  if (!t)
300
300
  throw h.providerMissing(this.params.sourceChain, "evm");
301
- const e = await q(
302
- v.LBTC,
301
+ const e = await U(
302
+ E.LBTC,
303
303
  this._chainId,
304
304
  this.ctx.env
305
305
  );
@@ -308,22 +308,22 @@ class bt extends S {
308
308
  "token",
309
309
  "Could not get LBTC token info"
310
310
  );
311
- const n = new D(this._amount), m = Z(
312
- y(n, e.decimals)
313
- ), u = this.getSpenderAddress(), d = x({ chainId: this._chainId }), c = z({
311
+ const n = new D(this._amount), d = Z(
312
+ q(n, e.decimals)
313
+ ), u = this.getSpenderAddress(), p = N({ chainId: this._chainId }), c = z({
314
314
  provider: t,
315
315
  chainId: this._chainId
316
- }), { request: E } = await d.simulateContract({
316
+ }), { request: _ } = await p.simulateContract({
317
317
  account: this._account,
318
- chain: b[this._chainId],
318
+ chain: M[this._chainId],
319
319
  address: e.address,
320
320
  abi: st,
321
321
  functionName: "approve",
322
- args: [u, m]
323
- }), _ = await c.writeContract(E);
324
- await U(
325
- d,
326
- _,
322
+ args: [u, d]
323
+ }), g = await c.writeContract(_);
324
+ await F(
325
+ p,
326
+ g,
327
327
  "LBTC deposit approval"
328
328
  ), this._needsApproval = !1, this.emitProgress({
329
329
  status: s.READY,
@@ -344,7 +344,7 @@ class bt extends S {
344
344
  });
345
345
  let e;
346
346
  return this.isVedaBtcePath() ? e = await Et({
347
- token: v.LBTC,
347
+ token: E.LBTC,
348
348
  amount: this._amount,
349
349
  receiver: this.params.recipient,
350
350
  approve: !1,
@@ -352,10 +352,10 @@ class bt extends S {
352
352
  chainId: this._chainId,
353
353
  provider: t,
354
354
  env: this.ctx.env
355
- }) : e = await Rt({
355
+ }) : e = await bt({
356
356
  amount: this._amount,
357
357
  approve: !1,
358
- token: v.LBTC,
358
+ token: E.LBTC,
359
359
  account: this._account,
360
360
  chainId: this._chainId,
361
361
  provider: t,
@@ -370,9 +370,9 @@ class bt extends S {
370
370
  }, s.COMPLETED);
371
371
  }
372
372
  get prepareSchema() {
373
- return N({
374
- amount: O,
375
- protocol: Tt().min(1, "Protocol is required")
373
+ return B({
374
+ amount: b,
375
+ protocol: Pt().min(1, "Protocol is required")
376
376
  });
377
377
  }
378
378
  validateProtocol(t) {
@@ -386,19 +386,19 @@ class bt extends S {
386
386
  }
387
387
  }
388
388
  function yt(r, a) {
389
- return new bt(r, a);
389
+ return new Rt(r, a);
390
390
  }
391
- const Mt = P(l.BTCb, [o.prod]), Ht = P(l.BTCb, [
391
+ const Mt = T(l.BTCb, [o.prod]), Ht = T(l.BTCb, [
392
392
  o.testnet,
393
393
  o.stage,
394
394
  o.dev,
395
395
  o.ibc
396
- ]), kt = P(l.LBTC, [o.prod]), Ft = P(l.LBTC, [
396
+ ]), kt = T(l.LBTC, [o.prod]), Ft = T(l.LBTC, [
397
397
  o.testnet,
398
398
  o.stage,
399
399
  o.dev,
400
400
  o.ibc
401
- ]), Yt = {
401
+ ]), qt = {
402
402
  routes: [
403
403
  // Production: BTCb → LBTC
404
404
  {
@@ -420,14 +420,14 @@ const Mt = P(l.BTCb, [o.prod]), Ht = P(l.BTCb, [
420
420
  addressSchema: rt
421
421
  };
422
422
  var f = /* @__PURE__ */ ((r) => (r.IDLE = "idle", r.NEEDS_APPROVAL = "needs-approval", r.READY = "ready", r.BRIDGING = "bridging", r.COMPLETED = "completed", r))(f || {});
423
- class qt extends S {
423
+ class Yt extends x {
424
424
  constructor(t, e) {
425
425
  super(f.IDLE);
426
- p(this, "_amount");
427
- p(this, "_recipient");
428
- p(this, "_needsApproval", !1);
429
- p(this, "_txHash");
430
- p(this, "_claimData");
426
+ m(this, "_amount");
427
+ m(this, "_recipient");
428
+ m(this, "_needsApproval", !1);
429
+ m(this, "_txHash");
430
+ m(this, "_claimData");
431
431
  this.ctx = t, this.params = e;
432
432
  }
433
433
  get amount() {
@@ -447,7 +447,7 @@ class qt extends S {
447
447
  }
448
448
  async prepare(t) {
449
449
  return this.assertStatus(f.IDLE, "prepare"), this.act(async () => {
450
- const e = L(this.prepareSchema, t, {
450
+ const e = O(this.prepareSchema, t, {
451
451
  destChain: this.params.destChain
452
452
  });
453
453
  this._amount = e.amount, this._recipient = e.recipient, this._needsApproval = !1, this.emitProgress({
@@ -472,7 +472,7 @@ class qt extends S {
472
472
  const t = await this.ctx.getProvider("evm");
473
473
  if (!t)
474
474
  throw h.providerMissing(this.params.sourceChain, "evm");
475
- const e = A(this.params.destChain);
475
+ const e = w(this.params.destChain);
476
476
  this.emitProgress({
477
477
  status: f.READY,
478
478
  steps: {
@@ -500,16 +500,16 @@ class qt extends S {
500
500
  }, f.COMPLETED);
501
501
  }
502
502
  get prepareSchema() {
503
- return N({
504
- amount: O,
505
- recipient: Yt.addressSchema
503
+ return B({
504
+ amount: b,
505
+ recipient: qt.addressSchema
506
506
  });
507
507
  }
508
508
  }
509
509
  function Vt(r, a) {
510
- return new qt(r, a);
510
+ return new Yt(r, a);
511
511
  }
512
- const Gt = P(l.BTCb, [o.prod]), $t = P(l.BTCb, [
512
+ const $t = T(l.BTCb, [o.prod]), Gt = T(l.BTCb, [
513
513
  o.testnet,
514
514
  o.stage,
515
515
  o.dev,
@@ -520,7 +520,7 @@ const Gt = P(l.BTCb, [o.prod]), $t = P(l.BTCb, [
520
520
  {
521
521
  assetIn: l.BTCb,
522
522
  assetOut: l.BTC,
523
- sourceChains: Gt,
523
+ sourceChains: $t,
524
524
  destChain: I.BITCOIN_MAINNET,
525
525
  envs: [o.prod]
526
526
  },
@@ -528,7 +528,7 @@ const Gt = P(l.BTCb, [o.prod]), $t = P(l.BTCb, [
528
528
  {
529
529
  assetIn: l.BTCb,
530
530
  assetOut: l.BTC,
531
- sourceChains: $t,
531
+ sourceChains: Gt,
532
532
  destChain: I.BITCOIN_SIGNET,
533
533
  envs: [o.testnet, o.stage, o.dev, o.ibc]
534
534
  }
@@ -546,44 +546,44 @@ async function K(r, a, t, e) {
546
546
  feeFormatted: null,
547
547
  expirationDate: null
548
548
  };
549
- const n = await W(e, r, t), m = await xt({
549
+ const n = await W(e, r, t), d = await xt({
550
550
  address: a,
551
551
  chainId: r,
552
552
  env: t,
553
553
  tokenAddress: n.address
554
- }), u = m.expirationDate ? new Date(Number(m.expirationDate) * 1e3) < /* @__PURE__ */ new Date() : !1, d = m.hasSignature && !u;
555
- let c = null, E = null;
556
- if (!d) {
557
- const _ = await at({
554
+ }), u = d.expirationDate ? new Date(Number(d.expirationDate) * 1e3) < /* @__PURE__ */ new Date() : !1, p = d.hasSignature && !u;
555
+ let c = null, _ = null;
556
+ if (!p) {
557
+ const g = await at({
558
558
  token: e,
559
559
  chainId: r,
560
560
  env: t
561
561
  });
562
- c = BigInt(_.times(1e8).toFixed(0)), E = _.toFixed(8);
562
+ c = BigInt(g.times(1e8).toFixed(0)), _ = g.toFixed(8);
563
563
  }
564
564
  return {
565
565
  requiresAuth: !0,
566
- hasValidSignature: d,
566
+ hasValidSignature: p,
567
567
  feeInSatoshis: c,
568
- feeFormatted: E,
569
- expirationDate: m.expirationDate ?? null
568
+ feeFormatted: _,
569
+ expirationDate: d.expirationDate ?? null
570
570
  };
571
571
  }
572
572
  async function Q(r) {
573
- const { chainId: a, account: t, feeInSatoshis: e, provider: n, env: m, token: u } = r, d = await W(u, a, m), c = await it({
573
+ const { chainId: a, account: t, feeInSatoshis: e, provider: n, env: d, token: u } = r, p = await W(u, a, d), c = await it({
574
574
  fee: e,
575
575
  account: t,
576
576
  chainId: a,
577
577
  provider: n,
578
- env: m,
578
+ env: d,
579
579
  token: u
580
580
  });
581
581
  return await Lt({
582
582
  signature: c.signature,
583
583
  typedData: c.typedData,
584
584
  address: t,
585
- env: m,
586
- tokenAddress: d.address
585
+ env: d,
586
+ tokenAddress: p.address
587
587
  }), c;
588
588
  }
589
589
  function J() {
@@ -595,14 +595,14 @@ function J() {
595
595
  expirationDate: null
596
596
  };
597
597
  }
598
- class zt extends S {
598
+ class zt extends x {
599
599
  constructor(t, e) {
600
600
  super(s.IDLE);
601
- p(this, "_amount");
602
- p(this, "_recipient");
603
- p(this, "_needsApproval", !1);
604
- p(this, "_txHash");
605
- p(this, "_feeAuth", J());
601
+ m(this, "_amount");
602
+ m(this, "_recipient");
603
+ m(this, "_needsApproval", !1);
604
+ m(this, "_txHash");
605
+ m(this, "_feeAuth", J());
606
606
  this.ctx = t, this.params = e;
607
607
  }
608
608
  get amount() {
@@ -623,20 +623,20 @@ class zt extends S {
623
623
  }
624
624
  async prepare(t) {
625
625
  return this.assertStatus(s.IDLE, "prepare"), this.act(async () => {
626
- const e = L(this.prepareSchema, t, {
626
+ const e = O(this.prepareSchema, t, {
627
627
  destChain: this.params.destChain
628
628
  });
629
629
  this._amount = e.amount, this._recipient = e.recipient;
630
- const n = A(this.params.sourceChain), m = await this.ctx.getProvider("evm");
631
- if (!m)
630
+ const n = w(this.params.sourceChain), d = await this.ctx.getProvider("evm");
631
+ if (!d)
632
632
  throw h.providerMissing(this.params.sourceChain, "evm");
633
- const d = (await m.request({
633
+ const p = (await d.request({
634
634
  method: "eth_accounts"
635
635
  }))[0], c = await K(
636
636
  n,
637
- d,
637
+ p,
638
638
  this.ctx.env,
639
- v.BTCb
639
+ E.BTCb
640
640
  );
641
641
  if (this._feeAuth = {
642
642
  requiresAuth: c.requiresAuth,
@@ -670,19 +670,19 @@ class zt extends S {
670
670
  ), !this._feeAuth.feeInSatoshis)
671
671
  throw h.missingParameter("feeInSatoshis");
672
672
  return this.act(async () => {
673
- const t = A(this.params.sourceChain), e = await this.ctx.getProvider("evm");
673
+ const t = w(this.params.sourceChain), e = await this.ctx.getProvider("evm");
674
674
  if (!e)
675
675
  throw h.providerMissing(this.params.sourceChain, "evm");
676
- const m = (await e.request({
676
+ const d = (await e.request({
677
677
  method: "eth_accounts"
678
678
  }))[0];
679
679
  await Q({
680
680
  chainId: t,
681
- account: m,
681
+ account: d,
682
682
  feeInSatoshis: this._feeAuth.feeInSatoshis,
683
683
  provider: e,
684
684
  env: this.ctx.env,
685
- token: v.BTCb
685
+ token: E.BTCb
686
686
  }), this._feeAuth.isAuthorized = !0, this.emitProgress({
687
687
  status: s.READY,
688
688
  steps: { burning: i.IDLE, releasing: i.IDLE }
@@ -707,7 +707,7 @@ class zt extends S {
707
707
  }))[0];
708
708
  if (!n)
709
709
  throw h.providerMissing(this.params.sourceChain, "evm");
710
- const m = A(this.params.sourceChain);
710
+ const d = w(this.params.sourceChain);
711
711
  this.emitProgress({
712
712
  status: s.READY,
713
713
  steps: { burning: i.PENDING, releasing: i.IDLE }
@@ -718,9 +718,9 @@ class zt extends S {
718
718
  amount: this._amount,
719
719
  btcAddress: this._recipient,
720
720
  // Bitcoin address to receive BTC
721
- chainId: m,
721
+ chainId: d,
722
722
  env: this.ctx.env,
723
- tokenIn: v.BTCb,
723
+ tokenIn: E.BTCb,
724
724
  tokenOut: void 0
725
725
  // Native BTC output
726
726
  });
@@ -731,8 +731,8 @@ class zt extends S {
731
731
  }, s.COMPLETED);
732
732
  }
733
733
  get prepareSchema() {
734
- return N({
735
- amount: O,
734
+ return B({
735
+ amount: b,
736
736
  recipient: Ut.recipientSchema
737
737
  });
738
738
  }
@@ -747,15 +747,15 @@ const Zt = [
747
747
  function jt(r) {
748
748
  return Zt.includes(r);
749
749
  }
750
- class Kt extends S {
750
+ class Kt extends x {
751
751
  constructor(t, e) {
752
752
  super(s.IDLE);
753
- p(this, "_amount");
754
- p(this, "_txHash");
755
- p(this, "_feeAuth", J());
756
- p(this, "_account");
757
- p(this, "_needsApproval", !1);
758
- p(this, "_spenderAddress");
753
+ m(this, "_amount");
754
+ m(this, "_txHash");
755
+ m(this, "_feeAuth", J());
756
+ m(this, "_account");
757
+ m(this, "_needsApproval", !1);
758
+ m(this, "_spenderAddress");
759
759
  this.ctx = t, this.params = e;
760
760
  }
761
761
  get amount() {
@@ -774,7 +774,7 @@ class Kt extends S {
774
774
  }
775
775
  async prepare(t) {
776
776
  return this.assertStatus(s.IDLE, "prepare"), this.act(async () => {
777
- const e = L(this.prepareSchema, t);
777
+ const e = O(this.prepareSchema, t);
778
778
  this._amount = e.amount;
779
779
  const n = await this.ctx.getProvider("evm");
780
780
  if (!n)
@@ -785,23 +785,23 @@ class Kt extends S {
785
785
  if (!u)
786
786
  throw h.providerMissing(this.params.sourceChain, "evm");
787
787
  this._account = u;
788
- const d = A(this.params.sourceChain);
789
- if (jt(d)) {
790
- const _ = await W(
791
- v.BTCb,
792
- d,
788
+ const p = w(this.params.sourceChain);
789
+ if (jt(p)) {
790
+ const g = await W(
791
+ E.BTCb,
792
+ p,
793
793
  this.ctx.env,
794
794
  Dt.Adapter
795
795
  );
796
- this._spenderAddress = _.address;
797
- const C = await _t({
798
- token: v.BTCb,
796
+ this._spenderAddress = g.address;
797
+ const v = await _t({
798
+ token: E.BTCb,
799
799
  owner: u,
800
- spender: _.address,
801
- chainId: d,
800
+ spender: g.address,
801
+ chainId: p,
802
802
  env: this.ctx.env
803
- }), g = new D(e.amount);
804
- if (this._needsApproval = C.isLessThan(g), this._needsApproval) {
803
+ }), C = new D(e.amount);
804
+ if (this._needsApproval = v.isLessThan(C), this._needsApproval) {
805
805
  this.emitProgress({
806
806
  status: s.NEEDS_APPROVAL,
807
807
  steps: { approval: i.PENDING, staking: i.IDLE }
@@ -810,10 +810,10 @@ class Kt extends S {
810
810
  }
811
811
  }
812
812
  const c = await K(
813
- d,
813
+ p,
814
814
  u,
815
815
  this.ctx.env,
816
- v.LBTC
816
+ E.LBTC
817
817
  );
818
818
  this._feeAuth = {
819
819
  requiresAuth: c.requiresAuth,
@@ -844,16 +844,16 @@ class Kt extends S {
844
844
  const t = await this.ctx.getProvider("evm");
845
845
  if (!t)
846
846
  throw h.providerMissing(this.params.sourceChain, "evm");
847
- const e = A(this.params.sourceChain), n = await gt({
847
+ const e = w(this.params.sourceChain), n = await gt({
848
848
  account: this._account,
849
- token: v.BTCb,
849
+ token: E.BTCb,
850
850
  spender: this._spenderAddress,
851
851
  amount: this._amount,
852
852
  chainId: e,
853
853
  provider: t,
854
854
  env: this.ctx.env
855
- }), m = x({ chainId: e, env: this.ctx.env });
856
- await U(m, n, "BTC.b approval"), this._needsApproval = !1, this.emitProgress({
855
+ }), d = N({ chainId: e, env: this.ctx.env });
856
+ await F(d, n, "BTC.b approval"), this._needsApproval = !1, this.emitProgress({
857
857
  status: s.READY,
858
858
  steps: { approval: i.COMPLETE, staking: i.PENDING }
859
859
  });
@@ -869,14 +869,14 @@ class Kt extends S {
869
869
  const t = await this.ctx.getProvider("evm");
870
870
  if (!t)
871
871
  throw h.providerMissing(this.params.sourceChain, "evm");
872
- const e = A(this.params.sourceChain);
872
+ const e = w(this.params.sourceChain);
873
873
  await Q({
874
874
  chainId: e,
875
875
  account: this._account,
876
876
  feeInSatoshis: this._feeAuth.feeInSatoshis,
877
877
  provider: t,
878
878
  env: this.ctx.env,
879
- token: v.LBTC
879
+ token: E.LBTC
880
880
  // BTC.b → LBTC uses LBTC token for fee signature
881
881
  }), this._feeAuth = {
882
882
  ...this._feeAuth,
@@ -892,20 +892,20 @@ class Kt extends S {
892
892
  const t = await this.ctx.getProvider("evm");
893
893
  if (!t)
894
894
  throw h.providerMissing(this.params.sourceChain, "evm");
895
- const e = A(this.params.sourceChain), m = (await t.request({
895
+ const e = w(this.params.sourceChain), d = (await t.request({
896
896
  method: "eth_accounts"
897
897
  }))[0];
898
- if (!m)
898
+ if (!d)
899
899
  throw h.providerMissing(this.params.sourceChain, "evm");
900
900
  this.emitProgress({
901
901
  status: s.READY,
902
902
  steps: { staking: i.PENDING }
903
903
  });
904
- const u = await At({
904
+ const u = await wt({
905
905
  amount: this._amount,
906
- tokenIn: v.BTCb,
907
- tokenOut: v.LBTC,
908
- account: m,
906
+ tokenIn: E.BTCb,
907
+ tokenOut: E.LBTC,
908
+ account: d,
909
909
  chainId: e,
910
910
  provider: t,
911
911
  env: this.ctx.env
@@ -917,15 +917,15 @@ class Kt extends S {
917
917
  }, s.COMPLETED);
918
918
  }
919
919
  get prepareSchema() {
920
- return N({
921
- amount: O
920
+ return B({
921
+ amount: b
922
922
  });
923
923
  }
924
924
  }
925
925
  function Qt(r, a) {
926
926
  return new Kt(r, a);
927
927
  }
928
- const Jt = P(l.LBTC, [o.prod]), Xt = P(l.LBTC, [
928
+ const Jt = T(l.LBTC, [o.prod]), Xt = T(l.LBTC, [
929
929
  o.testnet,
930
930
  o.stage,
931
931
  o.dev,
@@ -969,13 +969,13 @@ const Jt = P(l.LBTC, [o.prod]), Xt = P(l.LBTC, [
969
969
  ],
970
970
  recipientSchema: rt
971
971
  };
972
- class ie extends S {
972
+ class ie extends x {
973
973
  constructor(t, e) {
974
974
  super(s.IDLE);
975
- p(this, "_amount");
976
- p(this, "_recipient");
977
- p(this, "_txHash");
978
- p(this, "_feeAuth", J());
975
+ m(this, "_amount");
976
+ m(this, "_recipient");
977
+ m(this, "_txHash");
978
+ m(this, "_feeAuth", J());
979
979
  this.ctx = t, this.params = e;
980
980
  }
981
981
  get amount() {
@@ -997,22 +997,22 @@ class ie extends S {
997
997
  }
998
998
  async prepare(t) {
999
999
  return this.assertStatus(s.IDLE, "prepare"), this.act(async () => {
1000
- const e = L(this.prepareSchema, t, {
1000
+ const e = O(this.prepareSchema, t, {
1001
1001
  destChain: this.params.destChain
1002
1002
  });
1003
1003
  this._amount = e.amount, this._recipient = e.recipient;
1004
- const n = A(this.params.sourceChain);
1004
+ const n = w(this.params.sourceChain);
1005
1005
  if (this.isBtcbOutput) {
1006
- const m = await this.ctx.getProvider("evm");
1007
- if (!m)
1006
+ const d = await this.ctx.getProvider("evm");
1007
+ if (!d)
1008
1008
  throw h.providerMissing(this.params.sourceChain, "evm");
1009
- const d = (await m.request({
1009
+ const p = (await d.request({
1010
1010
  method: "eth_accounts"
1011
1011
  }))[0], c = await K(
1012
1012
  n,
1013
- d,
1013
+ p,
1014
1014
  this.ctx.env,
1015
- v.BTCb
1015
+ E.BTCb
1016
1016
  );
1017
1017
  if (this._feeAuth = {
1018
1018
  requiresAuth: c.requiresAuth,
@@ -1047,19 +1047,19 @@ class ie extends S {
1047
1047
  ), !this._feeAuth.feeInSatoshis)
1048
1048
  throw h.missingParameter("feeInSatoshis");
1049
1049
  return this.act(async () => {
1050
- const t = A(this.params.sourceChain), e = await this.ctx.getProvider("evm");
1050
+ const t = w(this.params.sourceChain), e = await this.ctx.getProvider("evm");
1051
1051
  if (!e)
1052
1052
  throw h.providerMissing(this.params.sourceChain, "evm");
1053
- const m = (await e.request({
1053
+ const d = (await e.request({
1054
1054
  method: "eth_accounts"
1055
1055
  }))[0];
1056
1056
  await Q({
1057
1057
  chainId: t,
1058
- account: m,
1058
+ account: d,
1059
1059
  feeInSatoshis: this._feeAuth.feeInSatoshis,
1060
1060
  provider: e,
1061
1061
  env: this.ctx.env,
1062
- token: v.BTCb
1062
+ token: E.BTCb
1063
1063
  }), this._feeAuth.isAuthorized = !0, this.emitProgress({
1064
1064
  status: s.READY,
1065
1065
  steps: { burning: i.IDLE, releasing: i.IDLE }
@@ -1076,34 +1076,34 @@ class ie extends S {
1076
1076
  }))[0];
1077
1077
  if (!n)
1078
1078
  throw h.providerMissing(this.params.sourceChain, "evm");
1079
- const m = A(this.params.sourceChain), u = this.params.assetOut === l.BTCb;
1079
+ const d = w(this.params.sourceChain), u = this.params.assetOut === l.BTCb;
1080
1080
  this.emitProgress({
1081
1081
  status: s.READY,
1082
1082
  steps: { burning: i.PENDING, releasing: i.IDLE }
1083
1083
  });
1084
- const d = await nt({
1084
+ const p = await nt({
1085
1085
  provider: t,
1086
1086
  account: u ? this._recipient : n,
1087
1087
  amount: this._amount,
1088
1088
  btcAddress: u ? void 0 : this._recipient,
1089
- chainId: m,
1089
+ chainId: d,
1090
1090
  env: this.ctx.env,
1091
- tokenIn: v.LBTC,
1092
- tokenOut: u ? v.BTCb : void 0
1091
+ tokenIn: E.LBTC,
1092
+ tokenOut: u ? E.BTCb : void 0
1093
1093
  });
1094
- return this._txHash = d, this.emitProgress({
1094
+ return this._txHash = p, this.emitProgress({
1095
1095
  status: s.COMPLETED,
1096
1096
  steps: {
1097
1097
  burning: i.COMPLETE,
1098
1098
  releasing: u ? i.COMPLETE : i.PENDING
1099
1099
  }
1100
- }), this.emitCompleted(), { txHash: d };
1100
+ }), this.emitCompleted(), { txHash: p };
1101
1101
  }, s.COMPLETED);
1102
1102
  }
1103
1103
  get prepareSchema() {
1104
1104
  const t = this.params.assetOut === l.BTC ? se : ae;
1105
- return N({
1106
- amount: O,
1105
+ return B({
1106
+ amount: b,
1107
1107
  recipient: t.recipientSchema
1108
1108
  });
1109
1109
  }
@@ -1116,17 +1116,17 @@ const ht = {
1116
1116
  // Veda - Ethereum, Base, BSC, Corn
1117
1117
  {
1118
1118
  sourceChains: [I.ETHEREUM, I.BASE, I.BSC, I.CORN],
1119
- protocols: [T.Veda],
1119
+ protocols: [S.Veda],
1120
1120
  envs: [o.prod]
1121
1121
  }
1122
1122
  ]
1123
1123
  };
1124
- class re extends S {
1124
+ class re extends x {
1125
1125
  constructor(t, e) {
1126
1126
  super(s.IDLE);
1127
- p(this, "_txHash");
1128
- p(this, "_account");
1129
- p(this, "_chainId");
1127
+ m(this, "_txHash");
1128
+ m(this, "_account");
1129
+ m(this, "_chainId");
1130
1130
  this.ctx = t, this.params = e;
1131
1131
  }
1132
1132
  get txHash() {
@@ -1143,9 +1143,9 @@ class re extends S {
1143
1143
  }))[0];
1144
1144
  if (!n)
1145
1145
  throw h.providerMissing(this.params.chain, "evm");
1146
- if (this._account = n, this._chainId = A(this.params.chain), !j(this._chainId))
1146
+ if (this._account = n, this._chainId = w(this.params.chain), !j(this._chainId))
1147
1147
  throw new h(
1148
- V.PROTOCOL_NOT_SUPPORTED,
1148
+ H.PROTOCOL_NOT_SUPPORTED,
1149
1149
  `Chain ${this.params.chain} does not support Veda vault withdrawals`,
1150
1150
  { chain: this.params.chain, protocol: this.params.protocol }
1151
1151
  );
@@ -1166,7 +1166,7 @@ class re extends S {
1166
1166
  status: s.READY,
1167
1167
  steps: { cancelling: i.PENDING }
1168
1168
  });
1169
- const e = await It({
1169
+ const e = await At({
1170
1170
  account: this._account,
1171
1171
  chainId: this._chainId,
1172
1172
  provider: t,
@@ -1188,15 +1188,15 @@ class re extends S {
1188
1188
  );
1189
1189
  }
1190
1190
  }
1191
- class oe extends S {
1191
+ class oe extends x {
1192
1192
  constructor(t, e) {
1193
1193
  super(s.IDLE);
1194
- p(this, "_amount");
1195
- p(this, "_protocol");
1196
- p(this, "_needsApproval", !1);
1197
- p(this, "_txHash");
1198
- p(this, "_account");
1199
- p(this, "_chainId");
1194
+ m(this, "_amount");
1195
+ m(this, "_protocol");
1196
+ m(this, "_needsApproval", !1);
1197
+ m(this, "_txHash");
1198
+ m(this, "_account");
1199
+ m(this, "_chainId");
1200
1200
  this.ctx = t, this.params = e;
1201
1201
  }
1202
1202
  get amount() {
@@ -1213,7 +1213,7 @@ class oe extends S {
1213
1213
  }
1214
1214
  async prepare(t) {
1215
1215
  return this.assertStatus(s.IDLE, "prepare"), this.act(async () => {
1216
- const e = L(this.prepareSchema, t);
1216
+ const e = O(this.prepareSchema, t);
1217
1217
  this._amount = e.amount, this._protocol = this.params.protocol, this.validateProtocol(this.params.protocol);
1218
1218
  const n = await this.ctx.getProvider("evm");
1219
1219
  if (!n)
@@ -1223,50 +1223,50 @@ class oe extends S {
1223
1223
  }))[0];
1224
1224
  if (!u)
1225
1225
  throw h.providerMissing(this.params.sourceChain, "evm");
1226
- if (this._account = u, this._chainId = A(this.params.sourceChain), !j(this._chainId))
1226
+ if (this._account = u, this._chainId = w(this.params.sourceChain), !j(this._chainId))
1227
1227
  throw new h(
1228
- V.PROTOCOL_NOT_SUPPORTED,
1228
+ H.PROTOCOL_NOT_SUPPORTED,
1229
1229
  `Chain ${this.params.sourceChain} does not support Veda vault withdrawals`,
1230
1230
  { chain: this.params.sourceChain, protocol: this._protocol }
1231
1231
  );
1232
- const d = M, c = x({ chainId: this._chainId }), E = new D(e.amount), _ = await c.readContract({
1233
- address: d.lensContract.address,
1234
- abi: d.lensContract.abi,
1232
+ const p = Y, c = N({ chainId: this._chainId }), _ = new D(e.amount), g = await c.readContract({
1233
+ address: p.lensContract.address,
1234
+ abi: p.lensContract.abi,
1235
1235
  functionName: "balanceOf",
1236
- args: [u, d.vaultContract.address]
1237
- }), C = B(
1238
- String(_),
1239
- d.decimals
1236
+ args: [u, p.vaultContract.address]
1237
+ }), v = y(
1238
+ String(g),
1239
+ p.decimals
1240
1240
  );
1241
- let g = C;
1242
- if (G(this._chainId)) {
1243
- const R = await c.readContract({
1244
- address: $.contracts[this._chainId],
1245
- abi: $.abi,
1241
+ let C = v;
1242
+ if (k(this._chainId)) {
1243
+ const L = await c.readContract({
1244
+ address: P.contracts[this._chainId],
1245
+ abi: P.abi,
1246
1246
  functionName: "balanceOf",
1247
1247
  args: [u]
1248
- }), k = B(
1249
- String(R),
1250
- d.decimals
1248
+ }), V = y(
1249
+ String(L),
1250
+ p.decimals
1251
1251
  );
1252
- g = C.plus(k);
1252
+ C = v.plus(V);
1253
1253
  }
1254
- if (E.isGreaterThan(g))
1254
+ if (_.isGreaterThan(C))
1255
1255
  throw new h(
1256
- V.INSUFFICIENT_SHARES,
1257
- `Insufficient vault shares. Requested: ${E.toFixed()}, Available: ${g.toFixed()}`,
1258
- { requested: E.toFixed(), available: g.toFixed() }
1256
+ H.INSUFFICIENT_SHARES,
1257
+ `Insufficient vault shares. Requested: ${_.toFixed()}, Available: ${C.toFixed()}`,
1258
+ { requested: _.toFixed(), available: C.toFixed() }
1259
1259
  );
1260
- const w = await c.readContract({
1261
- address: d.vaultContract.address,
1262
- abi: d.vaultContract.abi,
1260
+ const A = await c.readContract({
1261
+ address: p.vaultContract.address,
1262
+ abi: p.vaultContract.abi,
1263
1263
  functionName: "allowance",
1264
- args: [u, d.withdrawQueueContracts[this._chainId].address]
1265
- }), H = B(
1266
- String(w),
1267
- d.decimals
1264
+ args: [u, p.withdrawQueueContracts[this._chainId].address]
1265
+ }), R = y(
1266
+ String(A),
1267
+ p.decimals
1268
1268
  );
1269
- this._needsApproval = E.isGreaterThan(H), this._needsApproval ? (this.emitProgress({
1269
+ this._needsApproval = _.isGreaterThan(R), this._needsApproval ? (this.emitProgress({
1270
1270
  status: s.NEEDS_APPROVAL,
1271
1271
  steps: { approval: i.PENDING, queueing: i.IDLE }
1272
1272
  }), this.updateStatus(s.NEEDS_APPROVAL)) : (this.emitProgress({
@@ -1278,6 +1278,21 @@ class oe extends S {
1278
1278
  }), this.updateStatus(s.READY));
1279
1279
  });
1280
1280
  }
1281
+ /**
1282
+ * Approves the withdraw queue to pull vault shares.
1283
+ *
1284
+ * On BTCe-supported chains, when the user's direct LBTCv balance is below
1285
+ * the requested amount, unwraps the missing portion of BTCe BEFORE issuing
1286
+ * the approval. This is required because some wallets (e.g. OKX) display
1287
+ * the proposed approval amount as the user's current token balance with an
1288
+ * opt-in "set to unlimited" toggle. Approving first would let the wallet
1289
+ * silently cap the allowance at the pre-unwrap LBTCv balance, and the
1290
+ * subsequent queue tx in `execute()` would revert on insufficient allowance.
1291
+ *
1292
+ * Trade-off: on BTCe chains with insufficient LBTCv, this single step may
1293
+ * produce 2 wallet popups (unwrap + approve). On Corn (no BTCe) or when
1294
+ * direct LBTCv already covers the amount, only the approve popup is shown.
1295
+ */
1281
1296
  async approve() {
1282
1297
  return this.assertStatus(s.NEEDS_APPROVAL, "approve"), this.act(async () => {
1283
1298
  if (!this._account || !this._chainId || !this._amount)
@@ -1285,20 +1300,59 @@ class oe extends S {
1285
1300
  const t = await this.ctx.getProvider("evm");
1286
1301
  if (!t)
1287
1302
  throw h.providerMissing(this.params.sourceChain, "evm");
1288
- const e = M, n = new D(this._amount), m = Z(y(n, e.decimals)), u = x({ chainId: this._chainId }), d = z({
1303
+ const e = Y, n = new D(this._amount), d = Z(q(n, e.decimals)), u = N({ chainId: this._chainId }), p = z({
1289
1304
  provider: t,
1290
1305
  chainId: this._chainId
1291
- }), c = this._chainId, { request: E } = await u.simulateContract({
1306
+ }), c = this._chainId;
1307
+ if (k(this._chainId)) {
1308
+ const v = await u.readContract({
1309
+ address: e.lensContract.address,
1310
+ abi: e.lensContract.abi,
1311
+ functionName: "balanceOf",
1312
+ args: [this._account, e.vaultContract.address]
1313
+ });
1314
+ if (v < d) {
1315
+ const C = d - v, A = await u.readContract({
1316
+ address: P.contracts[this._chainId],
1317
+ abi: P.abi,
1318
+ functionName: "maxWithdraw",
1319
+ args: [this._account]
1320
+ });
1321
+ if (A < C)
1322
+ throw new h(
1323
+ H.INSUFFICIENT_SHARES,
1324
+ `BTCe wrapper cannot cover the required unwrap. needed=${C.toString()}, maxWithdraw=${A.toString()}.`,
1325
+ {
1326
+ needed: C.toString(),
1327
+ maxWithdraw: A.toString()
1328
+ }
1329
+ );
1330
+ const { request: R } = await u.simulateContract({
1331
+ account: this._account,
1332
+ chain: M[this._chainId],
1333
+ address: P.contracts[this._chainId],
1334
+ abi: P.abi,
1335
+ functionName: "withdraw",
1336
+ args: [C, this._account, this._account]
1337
+ }), L = await p.writeContract(R);
1338
+ await F(
1339
+ u,
1340
+ L,
1341
+ "BTCe unwrap"
1342
+ );
1343
+ }
1344
+ }
1345
+ const { request: _ } = await u.simulateContract({
1292
1346
  account: this._account,
1293
- chain: b[this._chainId],
1347
+ chain: M[this._chainId],
1294
1348
  address: e.vaultContract.address,
1295
1349
  abi: e.vaultContract.abi,
1296
1350
  functionName: "approve",
1297
- args: [e.withdrawQueueContracts[c].address, m]
1298
- }), _ = await d.writeContract(E);
1299
- await U(
1351
+ args: [e.withdrawQueueContracts[c].address, d]
1352
+ }), g = await p.writeContract(_);
1353
+ await F(
1300
1354
  u,
1301
- _,
1355
+ g,
1302
1356
  "vault share approval"
1303
1357
  ), this._needsApproval = !1, this.emitProgress({
1304
1358
  status: s.READY,
@@ -1318,13 +1372,13 @@ class oe extends S {
1318
1372
  steps: { approval: i.COMPLETE, queueing: i.PENDING }
1319
1373
  });
1320
1374
  let e;
1321
- return G(this._chainId) ? e = (await ft({
1375
+ return k(this._chainId) ? e = (await It({
1322
1376
  amount: this._amount,
1323
1377
  account: this._account,
1324
1378
  chainId: this._chainId,
1325
1379
  provider: t,
1326
1380
  env: this.ctx.env
1327
- })).queueTxHash : e = await wt({
1381
+ })).queueTxHash : e = await ft({
1328
1382
  amount: this._amount,
1329
1383
  approve: !1,
1330
1384
  account: this._account,
@@ -1338,8 +1392,8 @@ class oe extends S {
1338
1392
  }, s.COMPLETED);
1339
1393
  }
1340
1394
  get prepareSchema() {
1341
- return N({
1342
- amount: O
1395
+ return B({
1396
+ amount: b
1343
1397
  });
1344
1398
  }
1345
1399
  validateProtocol(t) {
@@ -1360,7 +1414,7 @@ function he(r, a) {
1360
1414
  }
1361
1415
  class ue {
1362
1416
  constructor(a) {
1363
- p(this, "ctx");
1417
+ m(this, "ctx");
1364
1418
  this.ctx = St(a);
1365
1419
  }
1366
1420
  /**
@@ -1496,13 +1550,13 @@ class ue {
1496
1550
  return Wt(this.ctx, a);
1497
1551
  }
1498
1552
  }
1499
- function Te(r) {
1553
+ function Pe(r) {
1500
1554
  return new ue(r);
1501
1555
  }
1502
1556
  export {
1503
1557
  ue as EvmActions,
1504
1558
  f as EvmDepositStatus,
1505
- Te as evmActions,
1506
- Pe as evmModule
1559
+ Pe as evmActions,
1560
+ Te as evmModule
1507
1561
  };
1508
- //# sourceMappingURL=EvmActions-CUKBeiUw.js.map
1562
+ //# sourceMappingURL=EvmActions-BGlhbADC.js.map