@lombard.finance/sdk 5.0.4 → 5.0.5
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/CHANGELOG.md +16 -0
- package/dist/btc.cjs +1 -1
- package/dist/btc.js +2 -2
- package/dist/chains/evm/EvmActions.d.ts +15 -6
- package/dist/chains/evm/EvmActions.d.ts.map +1 -1
- package/dist/chains/evm/actions/redeem/EvmRedeem.d.ts +15 -8
- package/dist/chains/evm/actions/redeem/EvmRedeem.d.ts.map +1 -1
- package/dist/chains/evm/actions/redeem/factory.d.ts +6 -2
- package/dist/chains/evm/actions/redeem/factory.d.ts.map +1 -1
- package/dist/chains/evm/actions/redeem/types.d.ts +10 -6
- package/dist/chains/evm/actions/redeem/types.d.ts.map +1 -1
- package/dist/chunks/{BtcActions-D7HekjRg.js → BtcActions-BDTnGE1D.js} +2 -2
- package/dist/chunks/{BtcActions-D7HekjRg.js.map → BtcActions-BDTnGE1D.js.map} +1 -1
- package/dist/chunks/{BtcActions-lp4P72ln.cjs → BtcActions-DZs5eXTb.cjs} +2 -2
- package/dist/chunks/{BtcActions-lp4P72ln.cjs.map → BtcActions-DZs5eXTb.cjs.map} +1 -1
- package/dist/chunks/{EvmActions-nbR8cSa4.js → EvmActions-8VeTiWrl.js} +337 -373
- package/dist/chunks/EvmActions-8VeTiWrl.js.map +1 -0
- package/dist/chunks/EvmActions-CEC3vNtR.cjs +7 -0
- package/dist/chunks/EvmActions-CEC3vNtR.cjs.map +1 -0
- package/dist/chunks/{events-BP_Ahnsm.js → events-22AhTtaL.js} +4 -4
- package/dist/chunks/{events-BP_Ahnsm.js.map → events-22AhTtaL.js.map} +1 -1
- package/dist/chunks/{events-DY2qn8Q0.cjs → events-CW_OMnKf.cjs} +2 -2
- package/dist/chunks/{events-DY2qn8Q0.cjs.map → events-CW_OMnKf.cjs.map} +1 -1
- package/dist/chunks/{statusConstants-D4DN05kK.cjs → statusConstants-Cz77HXnT.cjs} +2 -2
- package/dist/chunks/{statusConstants-D4DN05kK.cjs.map → statusConstants-Cz77HXnT.cjs.map} +1 -1
- package/dist/chunks/{statusConstants-DLrd03gT.js → statusConstants-DZlImWu7.js} +2 -2
- package/dist/chunks/{statusConstants-DLrd03gT.js.map → statusConstants-DZlImWu7.js.map} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +4 -4
- package/dist/evm.cjs +1 -1
- package/dist/evm.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunks/EvmActions-CynfSVFq.cjs +0 -7
- package/dist/chunks/EvmActions-CynfSVFq.cjs.map +0 -1
- package/dist/chunks/EvmActions-nbR8cSa4.js.map +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
var dt = Object.defineProperty;
|
|
2
|
-
var pt = (
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import { getMintingFee as
|
|
6
|
-
import { Token as
|
|
7
|
-
import { makePublicClient as N, getTokenInfo as U, toBaseDenomination as
|
|
8
|
-
import { Chain as
|
|
2
|
+
var pt = (n, a, t) => a in n ? dt(n, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[a] = t;
|
|
3
|
+
var d = (n, a, t) => pt(n, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import P from "bignumber.js";
|
|
5
|
+
import { getMintingFee as et, signNetworkFee as st, getStakeAndBakeFee as mt, signStakeAndBake as lt, signLbtcDestinationAddr as vt, waitForTransactionReceipt as F, depositEarn as Et, claimLBTC as Ct, redeemToken as at, getTokenAllowance as _t, approveToken as gt, depositToken as wt, cancelWithdrawInternal as At, withdrawEarn as ft, queueWithdrawInternal as It } from "./withdrawEarn-BM_JOe4k.js";
|
|
6
|
+
import { Token as C, makeWalletClient as W, CHAIN_ID_TO_VIEM_CHAIN_MAP as M, AddressKind as Pt, ChainId as X } from "./token-addresses-DVnRPyu4.js";
|
|
7
|
+
import { makePublicClient as N, getTokenInfo as U, toBaseDenomination as Y, fromBaseDenomination as y, getErrorMessage as Tt, getTokenContractInfo as z } from "./tokens-BUrC15ra.js";
|
|
8
|
+
import { Chain as A, BaseAction as x, EvmOperationStatus as s, validatePrepareParams as B, LombardError as h, parseChainIdentifier as f, StepStatus as i, objectType as O, evmAmountSchema as b, stringType as Dt, evmAddressSchema as it, getEvmAssetChains as T, bitcoinAddressSchema as nt, getEvmChainsWithAllAssets as rt, WithdrawErrorCode as H, createEvmCoreContext as St } from "./statusConstants-DZlImWu7.js";
|
|
9
9
|
import { storeNetworkFeeSignature as xt } from "./storeNetworkFeeSignature-sCt4_nHr.js";
|
|
10
10
|
import { requiresAutoMintFee as Lt } from "./fee-requirements-CCNsxAvJ.js";
|
|
11
11
|
import { getNetworkFeeSignature as Nt } from "./getNetworkFeeSignature-FuDJWrMC.js";
|
|
12
12
|
import { DefiProtocol as S, AssetId as l } from "./defi-registry-DULXbu3D.js";
|
|
13
13
|
import { r as o } from "./index-CfcQ_g3t.js";
|
|
14
|
-
import { erc20Abi as
|
|
14
|
+
import { erc20Abi as tt } from "viem";
|
|
15
15
|
import { toBigInt as Z } from "./numbers-CclN2Ohk.js";
|
|
16
|
-
import { isEarnChain as j, EARN_VAULT as
|
|
17
|
-
class
|
|
16
|
+
import { isEarnChain as j, EARN_VAULT as q, isBtceVaultChain as k, BTCE_VAULT as D } from "./config-wnjPtnjd.js";
|
|
17
|
+
class Bt {
|
|
18
18
|
constructor(a) {
|
|
19
19
|
this.env = a;
|
|
20
20
|
}
|
|
@@ -24,8 +24,8 @@ class Ot {
|
|
|
24
24
|
* @param token - Optional token (defaults to LBTC). Use Token.BTCb for BTC.b deposits.
|
|
25
25
|
*/
|
|
26
26
|
async getMintingFee(a, t) {
|
|
27
|
-
return (await
|
|
28
|
-
token: t ||
|
|
27
|
+
return (await et({
|
|
28
|
+
token: t || C.LBTC,
|
|
29
29
|
chainId: a,
|
|
30
30
|
env: this.env
|
|
31
31
|
})).toString();
|
|
@@ -34,14 +34,14 @@ class Ot {
|
|
|
34
34
|
* Sign network fee authorization (EIP-712)
|
|
35
35
|
*/
|
|
36
36
|
async signNetworkFee(a) {
|
|
37
|
-
const t = await
|
|
38
|
-
fee: new
|
|
37
|
+
const t = await st({
|
|
38
|
+
fee: new P(a.fee),
|
|
39
39
|
account: a.account,
|
|
40
40
|
chainId: a.chainId,
|
|
41
41
|
provider: a.provider,
|
|
42
42
|
env: this.env,
|
|
43
43
|
// Pass token for signing - defaults to LBTC for backwards compatibility
|
|
44
|
-
token: a.token ??
|
|
44
|
+
token: a.token ?? C.LBTC
|
|
45
45
|
});
|
|
46
46
|
return {
|
|
47
47
|
signature: t.signature,
|
|
@@ -62,7 +62,7 @@ class Ot {
|
|
|
62
62
|
*/
|
|
63
63
|
async signStakeAndBake(a) {
|
|
64
64
|
const t = await lt({
|
|
65
|
-
value: new
|
|
65
|
+
value: new P(a.value),
|
|
66
66
|
account: a.account,
|
|
67
67
|
chainId: a.chainId,
|
|
68
68
|
provider: a.provider,
|
|
@@ -86,79 +86,79 @@ class Ot {
|
|
|
86
86
|
}) };
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function De() {
|
|
90
90
|
return {
|
|
91
91
|
id: "evm",
|
|
92
92
|
chain: "evm",
|
|
93
|
-
register(
|
|
94
|
-
return new
|
|
93
|
+
register(n) {
|
|
94
|
+
return new Bt(n.env);
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
const
|
|
98
|
+
const Ot = {
|
|
99
99
|
routes: [
|
|
100
100
|
// Veda - Ethereum
|
|
101
101
|
{
|
|
102
102
|
asset: l.LBTC,
|
|
103
|
-
sourceChains: [
|
|
103
|
+
sourceChains: [A.ETHEREUM],
|
|
104
104
|
protocols: [S.Veda],
|
|
105
105
|
envs: [o.prod]
|
|
106
106
|
},
|
|
107
107
|
// Veda - Base
|
|
108
108
|
{
|
|
109
109
|
asset: l.LBTC,
|
|
110
|
-
sourceChains: [
|
|
110
|
+
sourceChains: [A.BASE],
|
|
111
111
|
protocols: [S.Veda],
|
|
112
112
|
envs: [o.prod]
|
|
113
113
|
},
|
|
114
114
|
// Veda - BSC
|
|
115
115
|
{
|
|
116
116
|
asset: l.LBTC,
|
|
117
|
-
sourceChains: [
|
|
117
|
+
sourceChains: [A.BSC],
|
|
118
118
|
protocols: [S.Veda],
|
|
119
119
|
envs: [o.prod]
|
|
120
120
|
},
|
|
121
121
|
// Veda - Corn
|
|
122
122
|
{
|
|
123
123
|
asset: l.LBTC,
|
|
124
|
-
sourceChains: [
|
|
124
|
+
sourceChains: [A.CORN],
|
|
125
125
|
protocols: [S.Veda],
|
|
126
126
|
envs: [o.prod]
|
|
127
127
|
},
|
|
128
128
|
// Silo - Avalanche
|
|
129
129
|
{
|
|
130
130
|
asset: l.LBTC,
|
|
131
|
-
sourceChains: [
|
|
131
|
+
sourceChains: [A.AVALANCHE],
|
|
132
132
|
protocols: [S.Silo],
|
|
133
133
|
envs: [o.prod]
|
|
134
134
|
}
|
|
135
135
|
]
|
|
136
136
|
};
|
|
137
137
|
async function bt({
|
|
138
|
-
amount:
|
|
138
|
+
amount: n,
|
|
139
139
|
approve: a = !0,
|
|
140
|
-
token: t =
|
|
140
|
+
token: t = C.LBTC,
|
|
141
141
|
account: e,
|
|
142
|
-
chainId:
|
|
143
|
-
provider:
|
|
144
|
-
rpcUrl:
|
|
142
|
+
chainId: r,
|
|
143
|
+
provider: m,
|
|
144
|
+
rpcUrl: c,
|
|
145
145
|
env: p
|
|
146
146
|
}) {
|
|
147
|
-
const
|
|
148
|
-
if (!j(
|
|
147
|
+
const u = q;
|
|
148
|
+
if (!j(r))
|
|
149
149
|
throw new Error(
|
|
150
|
-
`Unsupported chain id: ${
|
|
150
|
+
`Unsupported chain id: ${r}. Please switch to one of the supported chains: ${u.chains.join(", ")}`
|
|
151
151
|
);
|
|
152
|
-
const _ = N({ chainId:
|
|
152
|
+
const _ = N({ chainId: r, rpcUrl: c }), g = W({ provider: m, chainId: r }), v = await U(t, r, p, c);
|
|
153
153
|
if (!v)
|
|
154
154
|
throw new Error(`Unknown deposit token: ${t}`);
|
|
155
|
-
const
|
|
156
|
-
|
|
155
|
+
const E = P(n), w = Z(
|
|
156
|
+
Y(E, v.decimals)
|
|
157
157
|
), R = await _.readContract({
|
|
158
158
|
address: v.address,
|
|
159
159
|
abi: v.abi,
|
|
160
160
|
functionName: "allowance",
|
|
161
|
-
args: [e,
|
|
161
|
+
args: [e, u.vaultContract.address]
|
|
162
162
|
}), L = y(
|
|
163
163
|
String(R),
|
|
164
164
|
v.decimals
|
|
@@ -167,61 +167,61 @@ async function bt({
|
|
|
167
167
|
abi: v.abi,
|
|
168
168
|
functionName: "balanceOf",
|
|
169
169
|
args: [e]
|
|
170
|
-
}),
|
|
170
|
+
}), Q = y(
|
|
171
171
|
String(V),
|
|
172
172
|
v.decimals
|
|
173
173
|
);
|
|
174
|
-
if (
|
|
174
|
+
if (E.isGreaterThan(Q))
|
|
175
175
|
throw new Error(
|
|
176
176
|
`The deposit amount exceeds the account's balance.
|
|
177
|
-
Deposit amount: ${
|
|
178
|
-
Balance: ${
|
|
177
|
+
Deposit amount: ${E.toFixed()}
|
|
178
|
+
Balance: ${Q.toFixed()}`
|
|
179
179
|
);
|
|
180
|
-
if (
|
|
181
|
-
const
|
|
182
|
-
Deposit amount: ${
|
|
180
|
+
if (E.isGreaterThan(L)) {
|
|
181
|
+
const J = `The deposit amount exceeds allowance.
|
|
182
|
+
Deposit amount: ${E.toFixed()}
|
|
183
183
|
Allowance: ${L.toFixed()}`;
|
|
184
184
|
if (!a)
|
|
185
|
-
throw new Error(
|
|
186
|
-
console.info(
|
|
185
|
+
throw new Error(J);
|
|
186
|
+
console.info(J);
|
|
187
187
|
try {
|
|
188
|
-
console.info(`Trying to approve ${
|
|
188
|
+
console.info(`Trying to approve ${w}`);
|
|
189
189
|
const { request: $ } = await _.simulateContract({
|
|
190
190
|
account: e,
|
|
191
|
-
chain: M[
|
|
191
|
+
chain: M[r],
|
|
192
192
|
address: v.address,
|
|
193
193
|
abi: v.abi,
|
|
194
194
|
functionName: "approve",
|
|
195
|
-
args: [
|
|
195
|
+
args: [u.vaultContract.address, w]
|
|
196
196
|
}), G = await g.writeContract($);
|
|
197
|
-
console.info(`Approve tx hash: ${G}`), console.info(`Approved ${
|
|
197
|
+
console.info(`Approve tx hash: ${G}`), console.info(`Approved ${w} for ${u.vaultContract.address}`);
|
|
198
198
|
} catch ($) {
|
|
199
199
|
const G = Tt($);
|
|
200
200
|
throw new Error(
|
|
201
|
-
`Could not approve ${
|
|
201
|
+
`Could not approve ${w} for ${u.vaultContract.address}.
|
|
202
202
|
Reason: ${G}`
|
|
203
203
|
);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
const { request: ut } = await _.simulateContract({
|
|
207
207
|
account: e,
|
|
208
|
-
chain: M[
|
|
209
|
-
address:
|
|
210
|
-
abi:
|
|
208
|
+
chain: M[r],
|
|
209
|
+
address: u.tellerContracts[r].address,
|
|
210
|
+
abi: u.tellerContracts[r].abi,
|
|
211
211
|
functionName: "deposit",
|
|
212
|
-
args: [v.address,
|
|
212
|
+
args: [v.address, w, 0n]
|
|
213
213
|
});
|
|
214
214
|
return await g.writeContract(ut);
|
|
215
215
|
}
|
|
216
216
|
class Rt extends x {
|
|
217
217
|
constructor(t, e) {
|
|
218
218
|
super(s.IDLE);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
219
|
+
d(this, "_amount");
|
|
220
|
+
d(this, "_protocol");
|
|
221
|
+
d(this, "_needsApproval", !1);
|
|
222
|
+
d(this, "_txHash");
|
|
223
|
+
d(this, "_account");
|
|
224
|
+
d(this, "_chainId");
|
|
225
225
|
this.ctx = t, this.params = e;
|
|
226
226
|
}
|
|
227
227
|
get amount() {
|
|
@@ -249,23 +249,23 @@ class Rt extends x {
|
|
|
249
249
|
* - LBTCv BoringVault address for all other cases
|
|
250
250
|
*/
|
|
251
251
|
getSpenderAddress() {
|
|
252
|
-
return this.isVedaBtcePath() ?
|
|
252
|
+
return this.isVedaBtcePath() ? D.contracts[this._chainId] : q.vaultContract.address;
|
|
253
253
|
}
|
|
254
254
|
async prepare(t) {
|
|
255
255
|
return this.assertStatus(s.IDLE, "prepare"), this.act(async () => {
|
|
256
|
-
const e =
|
|
256
|
+
const e = B(this.prepareSchema, t);
|
|
257
257
|
this._amount = e.amount, this._protocol = t.protocol, this.validateProtocol(t.protocol);
|
|
258
|
-
const
|
|
259
|
-
if (!
|
|
258
|
+
const r = await this.ctx.getProvider("evm");
|
|
259
|
+
if (!r)
|
|
260
260
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
261
|
-
const
|
|
261
|
+
const c = (await r.request({
|
|
262
262
|
method: "eth_accounts"
|
|
263
263
|
}))[0];
|
|
264
|
-
if (!
|
|
264
|
+
if (!c)
|
|
265
265
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
266
|
-
this._account =
|
|
266
|
+
this._account = c, this._chainId = f(this.params.sourceChain);
|
|
267
267
|
const p = await U(
|
|
268
|
-
|
|
268
|
+
C.LBTC,
|
|
269
269
|
this._chainId,
|
|
270
270
|
this.ctx.env
|
|
271
271
|
);
|
|
@@ -274,13 +274,13 @@ class Rt extends x {
|
|
|
274
274
|
"token",
|
|
275
275
|
"Could not get LBTC token info"
|
|
276
276
|
);
|
|
277
|
-
const
|
|
277
|
+
const u = this.getSpenderAddress(), g = await N({ chainId: this._chainId }).readContract({
|
|
278
278
|
address: p.address,
|
|
279
|
-
abi:
|
|
279
|
+
abi: tt,
|
|
280
280
|
functionName: "allowance",
|
|
281
|
-
args: [
|
|
282
|
-
}), v = new
|
|
283
|
-
this._needsApproval =
|
|
281
|
+
args: [c, u]
|
|
282
|
+
}), v = new P(e.amount), E = Y(v, p.decimals), w = new P(String(g));
|
|
283
|
+
this._needsApproval = E.isGreaterThan(w), this._needsApproval ? (this.emitProgress({
|
|
284
284
|
status: s.NEEDS_APPROVAL,
|
|
285
285
|
steps: { approval: i.PENDING, deploying: i.IDLE }
|
|
286
286
|
}), this.updateStatus(s.NEEDS_APPROVAL)) : (this.emitProgress({
|
|
@@ -300,7 +300,7 @@ class Rt extends x {
|
|
|
300
300
|
if (!t)
|
|
301
301
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
302
302
|
const e = await U(
|
|
303
|
-
|
|
303
|
+
C.LBTC,
|
|
304
304
|
this._chainId,
|
|
305
305
|
this.ctx.env
|
|
306
306
|
);
|
|
@@ -309,19 +309,19 @@ class Rt extends x {
|
|
|
309
309
|
"token",
|
|
310
310
|
"Could not get LBTC token info"
|
|
311
311
|
);
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
),
|
|
312
|
+
const r = new P(this._amount), m = Z(
|
|
313
|
+
Y(r, e.decimals)
|
|
314
|
+
), c = this.getSpenderAddress(), p = N({ chainId: this._chainId }), u = W({
|
|
315
315
|
provider: t,
|
|
316
316
|
chainId: this._chainId
|
|
317
317
|
}), { request: _ } = await p.simulateContract({
|
|
318
318
|
account: this._account,
|
|
319
319
|
chain: M[this._chainId],
|
|
320
320
|
address: e.address,
|
|
321
|
-
abi:
|
|
321
|
+
abi: tt,
|
|
322
322
|
functionName: "approve",
|
|
323
|
-
args: [
|
|
324
|
-
}), g = await
|
|
323
|
+
args: [c, m]
|
|
324
|
+
}), g = await u.writeContract(_);
|
|
325
325
|
await F(
|
|
326
326
|
p,
|
|
327
327
|
g,
|
|
@@ -345,7 +345,7 @@ class Rt extends x {
|
|
|
345
345
|
});
|
|
346
346
|
let e;
|
|
347
347
|
return this.isVedaBtcePath() ? e = await Et({
|
|
348
|
-
token:
|
|
348
|
+
token: C.LBTC,
|
|
349
349
|
amount: this._amount,
|
|
350
350
|
receiver: this.params.recipient,
|
|
351
351
|
approve: !1,
|
|
@@ -356,7 +356,7 @@ class Rt extends x {
|
|
|
356
356
|
}) : e = await bt({
|
|
357
357
|
amount: this._amount,
|
|
358
358
|
approve: !1,
|
|
359
|
-
token:
|
|
359
|
+
token: C.LBTC,
|
|
360
360
|
account: this._account,
|
|
361
361
|
chainId: this._chainId,
|
|
362
362
|
provider: t,
|
|
@@ -371,14 +371,14 @@ class Rt extends x {
|
|
|
371
371
|
}, s.COMPLETED);
|
|
372
372
|
}
|
|
373
373
|
get prepareSchema() {
|
|
374
|
-
return
|
|
374
|
+
return O({
|
|
375
375
|
amount: b,
|
|
376
|
-
protocol:
|
|
376
|
+
protocol: Dt().min(1, "Protocol is required")
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
379
|
validateProtocol(t) {
|
|
380
|
-
if (!
|
|
381
|
-
(
|
|
380
|
+
if (!Ot.routes.some(
|
|
381
|
+
(r) => r.protocols.includes(t) && r.envs.includes(this.ctx.env)
|
|
382
382
|
))
|
|
383
383
|
throw h.invalidParameter(
|
|
384
384
|
"protocol",
|
|
@@ -386,8 +386,8 @@ class Rt extends x {
|
|
|
386
386
|
);
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
function yt(
|
|
390
|
-
return new Rt(
|
|
389
|
+
function yt(n, a) {
|
|
390
|
+
return new Rt(n, a);
|
|
391
391
|
}
|
|
392
392
|
const Mt = T(l.BTCb, [o.prod]), Ht = T(l.BTCb, [
|
|
393
393
|
o.testnet,
|
|
@@ -399,7 +399,7 @@ const Mt = T(l.BTCb, [o.prod]), Ht = T(l.BTCb, [
|
|
|
399
399
|
o.stage,
|
|
400
400
|
o.dev,
|
|
401
401
|
o.ibc
|
|
402
|
-
]),
|
|
402
|
+
]), Yt = {
|
|
403
403
|
routes: [
|
|
404
404
|
// Production: BTCb → LBTC
|
|
405
405
|
{
|
|
@@ -418,17 +418,17 @@ const Mt = T(l.BTCb, [o.prod]), Ht = T(l.BTCb, [
|
|
|
418
418
|
envs: [o.testnet, o.stage, o.dev, o.ibc]
|
|
419
419
|
}
|
|
420
420
|
],
|
|
421
|
-
addressSchema:
|
|
421
|
+
addressSchema: it
|
|
422
422
|
};
|
|
423
|
-
var I = /* @__PURE__ */ ((
|
|
424
|
-
class
|
|
423
|
+
var I = /* @__PURE__ */ ((n) => (n.IDLE = "idle", n.NEEDS_APPROVAL = "needs-approval", n.READY = "ready", n.BRIDGING = "bridging", n.COMPLETED = "completed", n))(I || {});
|
|
424
|
+
class qt extends x {
|
|
425
425
|
constructor(t, e) {
|
|
426
426
|
super(I.IDLE);
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
427
|
+
d(this, "_amount");
|
|
428
|
+
d(this, "_recipient");
|
|
429
|
+
d(this, "_needsApproval", !1);
|
|
430
|
+
d(this, "_txHash");
|
|
431
|
+
d(this, "_claimData");
|
|
432
432
|
this.ctx = t, this.params = e;
|
|
433
433
|
}
|
|
434
434
|
get amount() {
|
|
@@ -448,7 +448,7 @@ class Yt extends x {
|
|
|
448
448
|
}
|
|
449
449
|
async prepare(t) {
|
|
450
450
|
return this.assertStatus(I.IDLE, "prepare"), this.act(async () => {
|
|
451
|
-
const e =
|
|
451
|
+
const e = B(this.prepareSchema, t, {
|
|
452
452
|
destChain: this.params.destChain
|
|
453
453
|
});
|
|
454
454
|
this._amount = e.amount, this._recipient = e.recipient, this._needsApproval = !1, this.emitProgress({
|
|
@@ -473,7 +473,7 @@ class Yt extends x {
|
|
|
473
473
|
const t = await this.ctx.getProvider("evm");
|
|
474
474
|
if (!t)
|
|
475
475
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
476
|
-
const e =
|
|
476
|
+
const e = f(this.params.destChain);
|
|
477
477
|
this.emitProgress({
|
|
478
478
|
status: I.READY,
|
|
479
479
|
steps: {
|
|
@@ -482,7 +482,7 @@ class Yt extends x {
|
|
|
482
482
|
bridging: i.IDLE
|
|
483
483
|
}
|
|
484
484
|
});
|
|
485
|
-
const
|
|
485
|
+
const r = await Ct({
|
|
486
486
|
provider: t,
|
|
487
487
|
account: this._recipient,
|
|
488
488
|
data: this._claimData.data,
|
|
@@ -490,25 +490,25 @@ class Yt extends x {
|
|
|
490
490
|
chainId: e,
|
|
491
491
|
env: this.ctx.env
|
|
492
492
|
});
|
|
493
|
-
return this._txHash =
|
|
493
|
+
return this._txHash = r, this.emitProgress({
|
|
494
494
|
status: I.COMPLETED,
|
|
495
495
|
steps: {
|
|
496
496
|
approval: i.COMPLETE,
|
|
497
497
|
execution: i.COMPLETE,
|
|
498
498
|
bridging: i.IDLE
|
|
499
499
|
}
|
|
500
|
-
}), this.emitCompleted(), { txHash:
|
|
500
|
+
}), this.emitCompleted(), { txHash: r };
|
|
501
501
|
}, I.COMPLETED);
|
|
502
502
|
}
|
|
503
503
|
get prepareSchema() {
|
|
504
|
-
return
|
|
504
|
+
return O({
|
|
505
505
|
amount: b,
|
|
506
|
-
recipient:
|
|
506
|
+
recipient: Yt.addressSchema
|
|
507
507
|
});
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
-
function Vt(
|
|
511
|
-
return new
|
|
510
|
+
function Vt(n, a) {
|
|
511
|
+
return new qt(n, a);
|
|
512
512
|
}
|
|
513
513
|
const $t = T(l.BTCb, [o.prod]), Gt = T(l.BTCb, [
|
|
514
514
|
o.testnet,
|
|
@@ -522,7 +522,7 @@ const $t = T(l.BTCb, [o.prod]), Gt = T(l.BTCb, [
|
|
|
522
522
|
assetIn: l.BTCb,
|
|
523
523
|
assetOut: l.BTC,
|
|
524
524
|
sourceChains: $t,
|
|
525
|
-
destChain:
|
|
525
|
+
destChain: A.BITCOIN_MAINNET,
|
|
526
526
|
envs: [o.prod]
|
|
527
527
|
},
|
|
528
528
|
// BTC.b → BTC (to Bitcoin Signet - testnet)
|
|
@@ -530,16 +530,16 @@ const $t = T(l.BTCb, [o.prod]), Gt = T(l.BTCb, [
|
|
|
530
530
|
assetIn: l.BTCb,
|
|
531
531
|
assetOut: l.BTC,
|
|
532
532
|
sourceChains: Gt,
|
|
533
|
-
destChain:
|
|
533
|
+
destChain: A.BITCOIN_SIGNET,
|
|
534
534
|
envs: [o.testnet, o.stage, o.dev, o.ibc]
|
|
535
535
|
}
|
|
536
536
|
// TODO: Add L-Asset routes when deployed
|
|
537
537
|
// L-ZEC → ZEC, L-SOL → SOL, L-XRP → XRP, L-DOGE → DOGE
|
|
538
538
|
],
|
|
539
|
-
recipientSchema:
|
|
539
|
+
recipientSchema: nt
|
|
540
540
|
};
|
|
541
|
-
async function
|
|
542
|
-
if (!Lt(
|
|
541
|
+
async function ot(n, a, t, e) {
|
|
542
|
+
if (!Lt(n))
|
|
543
543
|
return {
|
|
544
544
|
requiresAuth: !1,
|
|
545
545
|
hasValidSignature: !1,
|
|
@@ -547,47 +547,47 @@ async function K(r, a, t, e) {
|
|
|
547
547
|
feeFormatted: null,
|
|
548
548
|
expirationDate: null
|
|
549
549
|
};
|
|
550
|
-
const
|
|
550
|
+
const r = await z(e, n, t), m = await Nt({
|
|
551
551
|
address: a,
|
|
552
|
-
chainId:
|
|
552
|
+
chainId: n,
|
|
553
553
|
env: t,
|
|
554
|
-
tokenAddress:
|
|
555
|
-
}),
|
|
556
|
-
let
|
|
554
|
+
tokenAddress: r.address
|
|
555
|
+
}), c = m.expirationDate ? new Date(Number(m.expirationDate) * 1e3) < /* @__PURE__ */ new Date() : !1, p = m.hasSignature && !c;
|
|
556
|
+
let u = null, _ = null;
|
|
557
557
|
if (!p) {
|
|
558
|
-
const g = await
|
|
558
|
+
const g = await et({
|
|
559
559
|
token: e,
|
|
560
|
-
chainId:
|
|
560
|
+
chainId: n,
|
|
561
561
|
env: t
|
|
562
562
|
});
|
|
563
|
-
|
|
563
|
+
u = BigInt(g.times(1e8).toFixed(0)), _ = g.toFixed(8);
|
|
564
564
|
}
|
|
565
565
|
return {
|
|
566
566
|
requiresAuth: !0,
|
|
567
567
|
hasValidSignature: p,
|
|
568
|
-
feeInSatoshis:
|
|
568
|
+
feeInSatoshis: u,
|
|
569
569
|
feeFormatted: _,
|
|
570
|
-
expirationDate:
|
|
570
|
+
expirationDate: m.expirationDate ?? null
|
|
571
571
|
};
|
|
572
572
|
}
|
|
573
|
-
async function
|
|
574
|
-
const { chainId: a, account: t, feeInSatoshis: e, provider:
|
|
573
|
+
async function ct(n) {
|
|
574
|
+
const { chainId: a, account: t, feeInSatoshis: e, provider: r, env: m, token: c } = n, p = await z(c, a, m), u = await st({
|
|
575
575
|
fee: e,
|
|
576
576
|
account: t,
|
|
577
577
|
chainId: a,
|
|
578
|
-
provider:
|
|
579
|
-
env:
|
|
580
|
-
token:
|
|
578
|
+
provider: r,
|
|
579
|
+
env: m,
|
|
580
|
+
token: c
|
|
581
581
|
});
|
|
582
582
|
return await xt({
|
|
583
|
-
signature:
|
|
584
|
-
typedData:
|
|
583
|
+
signature: u.signature,
|
|
584
|
+
typedData: u.typedData,
|
|
585
585
|
address: t,
|
|
586
|
-
env:
|
|
586
|
+
env: m,
|
|
587
587
|
tokenAddress: p.address
|
|
588
|
-
}),
|
|
588
|
+
}), u;
|
|
589
589
|
}
|
|
590
|
-
function
|
|
590
|
+
function K() {
|
|
591
591
|
return {
|
|
592
592
|
requiresAuth: !1,
|
|
593
593
|
isAuthorized: !1,
|
|
@@ -596,14 +596,14 @@ function J() {
|
|
|
596
596
|
expirationDate: null
|
|
597
597
|
};
|
|
598
598
|
}
|
|
599
|
-
class
|
|
599
|
+
class Wt extends x {
|
|
600
600
|
constructor(t, e) {
|
|
601
601
|
super(s.IDLE);
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
602
|
+
d(this, "_amount");
|
|
603
|
+
d(this, "_recipient");
|
|
604
|
+
d(this, "_needsApproval", !1);
|
|
605
|
+
d(this, "_txHash");
|
|
606
|
+
d(this, "_feeAuth", K());
|
|
607
607
|
this.ctx = t, this.params = e;
|
|
608
608
|
}
|
|
609
609
|
get amount() {
|
|
@@ -624,71 +624,26 @@ class zt extends x {
|
|
|
624
624
|
}
|
|
625
625
|
async prepare(t) {
|
|
626
626
|
return this.assertStatus(s.IDLE, "prepare"), this.act(async () => {
|
|
627
|
-
const e =
|
|
627
|
+
const e = B(this.prepareSchema, t, {
|
|
628
628
|
destChain: this.params.destChain
|
|
629
629
|
});
|
|
630
|
-
this._amount = e.amount, this._recipient = e.recipient
|
|
631
|
-
const n = w(this.params.sourceChain), d = await this.ctx.getProvider("evm");
|
|
632
|
-
if (!d)
|
|
633
|
-
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
634
|
-
const p = (await d.request({
|
|
635
|
-
method: "eth_accounts"
|
|
636
|
-
}))[0], c = await K(
|
|
637
|
-
n,
|
|
638
|
-
p,
|
|
639
|
-
this.ctx.env,
|
|
640
|
-
E.BTCb
|
|
641
|
-
);
|
|
642
|
-
if (this._feeAuth = {
|
|
643
|
-
requiresAuth: c.requiresAuth,
|
|
644
|
-
isAuthorized: c.hasValidSignature,
|
|
645
|
-
feeInSatoshis: c.feeInSatoshis,
|
|
646
|
-
feeFormatted: c.feeFormatted,
|
|
647
|
-
expirationDate: c.expirationDate
|
|
648
|
-
}, c.requiresAuth && !c.hasValidSignature) {
|
|
649
|
-
this.updateStatus(s.NEEDS_FEE_AUTHORIZATION), this.emitProgress({
|
|
650
|
-
status: s.NEEDS_FEE_AUTHORIZATION,
|
|
651
|
-
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
652
|
-
});
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
655
|
-
this._needsApproval = !1, this.updateStatus(s.READY), this.emitProgress({
|
|
630
|
+
this._amount = e.amount, this._recipient = e.recipient, this._needsApproval = !1, this.emitProgress({
|
|
656
631
|
status: s.READY,
|
|
657
632
|
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
658
633
|
});
|
|
659
|
-
});
|
|
634
|
+
}, s.READY);
|
|
660
635
|
}
|
|
661
636
|
/**
|
|
662
637
|
* Authorize the network fee
|
|
663
638
|
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
639
|
+
* @deprecated EVM Redeem no longer requires fee authorization. The status
|
|
640
|
+
* machine never reaches `NEEDS_FEE_AUTHORIZATION`, so this method is a
|
|
641
|
+
* safe no-op kept only for backwards compatibility with the existing
|
|
642
|
+
* public interface. Calling it on a `READY` (or any other) status will
|
|
643
|
+
* resolve immediately without touching the wallet, the API, or the action
|
|
644
|
+
* state.
|
|
666
645
|
*/
|
|
667
646
|
async authorizeFee() {
|
|
668
|
-
if (this.assertStatus(
|
|
669
|
-
s.NEEDS_FEE_AUTHORIZATION,
|
|
670
|
-
"authorizeFee"
|
|
671
|
-
), !this._feeAuth.feeInSatoshis)
|
|
672
|
-
throw h.missingParameter("feeInSatoshis");
|
|
673
|
-
return this.act(async () => {
|
|
674
|
-
const t = w(this.params.sourceChain), e = await this.ctx.getProvider("evm");
|
|
675
|
-
if (!e)
|
|
676
|
-
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
677
|
-
const d = (await e.request({
|
|
678
|
-
method: "eth_accounts"
|
|
679
|
-
}))[0];
|
|
680
|
-
await Q({
|
|
681
|
-
chainId: t,
|
|
682
|
-
account: d,
|
|
683
|
-
feeInSatoshis: this._feeAuth.feeInSatoshis,
|
|
684
|
-
provider: e,
|
|
685
|
-
env: this.ctx.env,
|
|
686
|
-
token: E.BTCb
|
|
687
|
-
}), this._feeAuth.isAuthorized = !0, this.emitProgress({
|
|
688
|
-
status: s.READY,
|
|
689
|
-
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
690
|
-
});
|
|
691
|
-
}, s.READY);
|
|
692
647
|
}
|
|
693
648
|
async approve() {
|
|
694
649
|
return this.assertStatus(s.NEEDS_APPROVAL, "approve"), this.act(async () => {
|
|
@@ -703,60 +658,60 @@ class zt extends x {
|
|
|
703
658
|
const t = await this.ctx.getProvider("evm");
|
|
704
659
|
if (!t)
|
|
705
660
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
706
|
-
const
|
|
661
|
+
const r = (await t.request({
|
|
707
662
|
method: "eth_accounts"
|
|
708
663
|
}))[0];
|
|
709
|
-
if (!
|
|
664
|
+
if (!r)
|
|
710
665
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
711
|
-
const
|
|
666
|
+
const m = f(this.params.sourceChain);
|
|
712
667
|
this.emitProgress({
|
|
713
668
|
status: s.READY,
|
|
714
669
|
steps: { burning: i.PENDING, releasing: i.IDLE }
|
|
715
670
|
});
|
|
716
|
-
const
|
|
671
|
+
const c = await at({
|
|
717
672
|
provider: t,
|
|
718
|
-
account:
|
|
673
|
+
account: r,
|
|
719
674
|
amount: this._amount,
|
|
720
675
|
btcAddress: this._recipient,
|
|
721
676
|
// Bitcoin address to receive BTC
|
|
722
|
-
chainId:
|
|
677
|
+
chainId: m,
|
|
723
678
|
env: this.ctx.env,
|
|
724
|
-
tokenIn:
|
|
679
|
+
tokenIn: C.BTCb,
|
|
725
680
|
tokenOut: void 0
|
|
726
681
|
// Native BTC output
|
|
727
682
|
});
|
|
728
|
-
return this._txHash =
|
|
683
|
+
return this._txHash = c, this.emitProgress({
|
|
729
684
|
status: s.COMPLETED,
|
|
730
685
|
steps: { burning: i.COMPLETE, releasing: i.PENDING }
|
|
731
|
-
}), this.emitCompleted(), { txHash:
|
|
686
|
+
}), this.emitCompleted(), { txHash: c };
|
|
732
687
|
}, s.COMPLETED);
|
|
733
688
|
}
|
|
734
689
|
get prepareSchema() {
|
|
735
|
-
return
|
|
690
|
+
return O({
|
|
736
691
|
amount: b,
|
|
737
692
|
recipient: Ut.recipientSchema
|
|
738
693
|
});
|
|
739
694
|
}
|
|
740
695
|
}
|
|
741
|
-
function
|
|
742
|
-
return new
|
|
696
|
+
function zt(n, a) {
|
|
697
|
+
return new Wt(n, a);
|
|
743
698
|
}
|
|
744
699
|
const Zt = [
|
|
745
|
-
|
|
746
|
-
|
|
700
|
+
X.avalanche,
|
|
701
|
+
X.avalancheFuji
|
|
747
702
|
];
|
|
748
|
-
function jt(
|
|
749
|
-
return Zt.includes(
|
|
703
|
+
function jt(n) {
|
|
704
|
+
return Zt.includes(n);
|
|
750
705
|
}
|
|
751
706
|
class Kt extends x {
|
|
752
707
|
constructor(t, e) {
|
|
753
708
|
super(s.IDLE);
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
709
|
+
d(this, "_amount");
|
|
710
|
+
d(this, "_txHash");
|
|
711
|
+
d(this, "_feeAuth", K());
|
|
712
|
+
d(this, "_account");
|
|
713
|
+
d(this, "_needsApproval", !1);
|
|
714
|
+
d(this, "_spenderAddress");
|
|
760
715
|
this.ctx = t, this.params = e;
|
|
761
716
|
}
|
|
762
717
|
get amount() {
|
|
@@ -775,34 +730,34 @@ class Kt extends x {
|
|
|
775
730
|
}
|
|
776
731
|
async prepare(t) {
|
|
777
732
|
return this.assertStatus(s.IDLE, "prepare"), this.act(async () => {
|
|
778
|
-
const e =
|
|
733
|
+
const e = B(this.prepareSchema, t);
|
|
779
734
|
this._amount = e.amount;
|
|
780
|
-
const
|
|
781
|
-
if (!
|
|
735
|
+
const r = await this.ctx.getProvider("evm");
|
|
736
|
+
if (!r)
|
|
782
737
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
783
|
-
const
|
|
738
|
+
const c = (await r.request({
|
|
784
739
|
method: "eth_accounts"
|
|
785
740
|
}))[0];
|
|
786
|
-
if (!
|
|
741
|
+
if (!c)
|
|
787
742
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
788
|
-
this._account =
|
|
789
|
-
const p =
|
|
743
|
+
this._account = c;
|
|
744
|
+
const p = f(this.params.sourceChain);
|
|
790
745
|
if (jt(p)) {
|
|
791
|
-
const g = await
|
|
792
|
-
|
|
746
|
+
const g = await z(
|
|
747
|
+
C.BTCb,
|
|
793
748
|
p,
|
|
794
749
|
this.ctx.env,
|
|
795
|
-
|
|
750
|
+
Pt.Adapter
|
|
796
751
|
);
|
|
797
752
|
this._spenderAddress = g.address;
|
|
798
753
|
const v = await _t({
|
|
799
|
-
token:
|
|
800
|
-
owner:
|
|
754
|
+
token: C.BTCb,
|
|
755
|
+
owner: c,
|
|
801
756
|
spender: g.address,
|
|
802
757
|
chainId: p,
|
|
803
758
|
env: this.ctx.env
|
|
804
|
-
}),
|
|
805
|
-
if (this._needsApproval = v.isLessThan(
|
|
759
|
+
}), E = new P(e.amount);
|
|
760
|
+
if (this._needsApproval = v.isLessThan(E), this._needsApproval) {
|
|
806
761
|
this.emitProgress({
|
|
807
762
|
status: s.NEEDS_APPROVAL,
|
|
808
763
|
steps: { approval: i.PENDING, staking: i.IDLE }
|
|
@@ -810,19 +765,19 @@ class Kt extends x {
|
|
|
810
765
|
return;
|
|
811
766
|
}
|
|
812
767
|
}
|
|
813
|
-
const
|
|
768
|
+
const u = await ot(
|
|
814
769
|
p,
|
|
815
|
-
|
|
770
|
+
c,
|
|
816
771
|
this.ctx.env,
|
|
817
|
-
|
|
772
|
+
C.LBTC
|
|
818
773
|
);
|
|
819
774
|
this._feeAuth = {
|
|
820
|
-
requiresAuth:
|
|
821
|
-
isAuthorized:
|
|
822
|
-
feeInSatoshis:
|
|
823
|
-
feeFormatted:
|
|
824
|
-
expirationDate:
|
|
825
|
-
},
|
|
775
|
+
requiresAuth: u.requiresAuth,
|
|
776
|
+
isAuthorized: u.hasValidSignature,
|
|
777
|
+
feeInSatoshis: u.feeInSatoshis,
|
|
778
|
+
feeFormatted: u.feeFormatted,
|
|
779
|
+
expirationDate: u.expirationDate
|
|
780
|
+
}, u.requiresAuth && !u.hasValidSignature ? (this.emitProgress({
|
|
826
781
|
status: s.NEEDS_FEE_AUTHORIZATION,
|
|
827
782
|
steps: { staking: i.IDLE }
|
|
828
783
|
}), this.updateStatus(s.NEEDS_FEE_AUTHORIZATION)) : (this.emitProgress({
|
|
@@ -845,16 +800,16 @@ class Kt extends x {
|
|
|
845
800
|
const t = await this.ctx.getProvider("evm");
|
|
846
801
|
if (!t)
|
|
847
802
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
848
|
-
const e =
|
|
803
|
+
const e = f(this.params.sourceChain), r = await gt({
|
|
849
804
|
account: this._account,
|
|
850
|
-
token:
|
|
805
|
+
token: C.BTCb,
|
|
851
806
|
spender: this._spenderAddress,
|
|
852
807
|
amount: this._amount,
|
|
853
808
|
chainId: e,
|
|
854
809
|
provider: t,
|
|
855
810
|
env: this.ctx.env
|
|
856
|
-
}),
|
|
857
|
-
await F(
|
|
811
|
+
}), m = N({ chainId: e, env: this.ctx.env });
|
|
812
|
+
await F(m, r, "BTC.b approval"), this._needsApproval = !1, this.emitProgress({
|
|
858
813
|
status: s.READY,
|
|
859
814
|
steps: { approval: i.COMPLETE, staking: i.PENDING }
|
|
860
815
|
});
|
|
@@ -870,14 +825,14 @@ class Kt extends x {
|
|
|
870
825
|
const t = await this.ctx.getProvider("evm");
|
|
871
826
|
if (!t)
|
|
872
827
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
873
|
-
const e =
|
|
874
|
-
await
|
|
828
|
+
const e = f(this.params.sourceChain);
|
|
829
|
+
await ct({
|
|
875
830
|
chainId: e,
|
|
876
831
|
account: this._account,
|
|
877
832
|
feeInSatoshis: this._feeAuth.feeInSatoshis,
|
|
878
833
|
provider: t,
|
|
879
834
|
env: this.ctx.env,
|
|
880
|
-
token:
|
|
835
|
+
token: C.LBTC
|
|
881
836
|
// BTC.b → LBTC uses LBTC token for fee signature
|
|
882
837
|
}), this._feeAuth = {
|
|
883
838
|
...this._feeAuth,
|
|
@@ -893,48 +848,48 @@ class Kt extends x {
|
|
|
893
848
|
const t = await this.ctx.getProvider("evm");
|
|
894
849
|
if (!t)
|
|
895
850
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
896
|
-
const e =
|
|
851
|
+
const e = f(this.params.sourceChain), m = (await t.request({
|
|
897
852
|
method: "eth_accounts"
|
|
898
853
|
}))[0];
|
|
899
|
-
if (!
|
|
854
|
+
if (!m)
|
|
900
855
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
901
856
|
this.emitProgress({
|
|
902
857
|
status: s.READY,
|
|
903
858
|
steps: { staking: i.PENDING }
|
|
904
859
|
});
|
|
905
|
-
const
|
|
860
|
+
const c = await wt({
|
|
906
861
|
amount: this._amount,
|
|
907
|
-
tokenIn:
|
|
908
|
-
tokenOut:
|
|
909
|
-
account:
|
|
862
|
+
tokenIn: C.BTCb,
|
|
863
|
+
tokenOut: C.LBTC,
|
|
864
|
+
account: m,
|
|
910
865
|
chainId: e,
|
|
911
866
|
provider: t,
|
|
912
867
|
env: this.ctx.env
|
|
913
868
|
});
|
|
914
|
-
return this._txHash =
|
|
869
|
+
return this._txHash = c, this.emitProgress({
|
|
915
870
|
status: s.COMPLETED,
|
|
916
871
|
steps: { staking: i.COMPLETE }
|
|
917
|
-
}), this.emitCompleted(), { txHash:
|
|
872
|
+
}), this.emitCompleted(), { txHash: c };
|
|
918
873
|
}, s.COMPLETED);
|
|
919
874
|
}
|
|
920
875
|
get prepareSchema() {
|
|
921
|
-
return
|
|
876
|
+
return O({
|
|
922
877
|
amount: b
|
|
923
878
|
});
|
|
924
879
|
}
|
|
925
880
|
}
|
|
926
|
-
function Qt(
|
|
927
|
-
return new Kt(
|
|
881
|
+
function Qt(n, a) {
|
|
882
|
+
return new Kt(n, a);
|
|
928
883
|
}
|
|
929
884
|
const Jt = T(l.LBTC, [o.prod]), Xt = T(l.LBTC, [
|
|
930
885
|
o.testnet,
|
|
931
886
|
o.stage,
|
|
932
887
|
o.dev,
|
|
933
888
|
o.ibc
|
|
934
|
-
]), te =
|
|
889
|
+
]), te = rt(
|
|
935
890
|
[l.LBTC, l.BTCb],
|
|
936
891
|
[o.prod]
|
|
937
|
-
), ee =
|
|
892
|
+
), ee = rt(
|
|
938
893
|
[l.LBTC, l.BTCb],
|
|
939
894
|
[o.testnet, o.stage, o.dev, o.ibc]
|
|
940
895
|
), se = {
|
|
@@ -942,41 +897,41 @@ const Jt = T(l.LBTC, [o.prod]), Xt = T(l.LBTC, [
|
|
|
942
897
|
// Production: EVM chains with LBTC → Bitcoin Mainnet
|
|
943
898
|
{
|
|
944
899
|
sourceChains: Jt,
|
|
945
|
-
destChain:
|
|
900
|
+
destChain: A.BITCOIN_MAINNET,
|
|
946
901
|
envs: [o.prod]
|
|
947
902
|
},
|
|
948
903
|
// Testnet: EVM chains with LBTC → Bitcoin Signet
|
|
949
904
|
{
|
|
950
905
|
sourceChains: Xt,
|
|
951
|
-
destChain:
|
|
906
|
+
destChain: A.BITCOIN_SIGNET,
|
|
952
907
|
envs: [o.testnet, o.stage, o.dev, o.ibc]
|
|
953
908
|
}
|
|
954
909
|
],
|
|
955
|
-
recipientSchema:
|
|
910
|
+
recipientSchema: nt
|
|
956
911
|
}, ae = {
|
|
957
912
|
routes: [
|
|
958
913
|
// Production: Same-chain routes for chains with both LBTC and BTCb
|
|
959
|
-
...te.map((
|
|
960
|
-
sourceChains: [
|
|
961
|
-
destChain:
|
|
914
|
+
...te.map((n) => ({
|
|
915
|
+
sourceChains: [n],
|
|
916
|
+
destChain: n,
|
|
962
917
|
envs: [o.prod]
|
|
963
918
|
})),
|
|
964
919
|
// Testnet: Same-chain routes
|
|
965
|
-
...ee.map((
|
|
966
|
-
sourceChains: [
|
|
967
|
-
destChain:
|
|
920
|
+
...ee.map((n) => ({
|
|
921
|
+
sourceChains: [n],
|
|
922
|
+
destChain: n,
|
|
968
923
|
envs: [o.testnet, o.stage, o.dev, o.ibc]
|
|
969
924
|
}))
|
|
970
925
|
],
|
|
971
|
-
recipientSchema:
|
|
926
|
+
recipientSchema: it
|
|
972
927
|
};
|
|
973
928
|
class ie extends x {
|
|
974
929
|
constructor(t, e) {
|
|
975
930
|
super(s.IDLE);
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
931
|
+
d(this, "_amount");
|
|
932
|
+
d(this, "_recipient");
|
|
933
|
+
d(this, "_txHash");
|
|
934
|
+
d(this, "_feeAuth", K());
|
|
980
935
|
this.ctx = t, this.params = e;
|
|
981
936
|
}
|
|
982
937
|
get amount() {
|
|
@@ -998,30 +953,30 @@ class ie extends x {
|
|
|
998
953
|
}
|
|
999
954
|
async prepare(t) {
|
|
1000
955
|
return this.assertStatus(s.IDLE, "prepare"), this.act(async () => {
|
|
1001
|
-
const e =
|
|
956
|
+
const e = B(this.prepareSchema, t, {
|
|
1002
957
|
destChain: this.params.destChain
|
|
1003
958
|
});
|
|
1004
959
|
this._amount = e.amount, this._recipient = e.recipient;
|
|
1005
|
-
const
|
|
960
|
+
const r = f(this.params.sourceChain);
|
|
1006
961
|
if (this.isBtcbOutput) {
|
|
1007
|
-
const
|
|
1008
|
-
if (!
|
|
962
|
+
const m = await this.ctx.getProvider("evm");
|
|
963
|
+
if (!m)
|
|
1009
964
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
1010
|
-
const p = (await
|
|
965
|
+
const p = (await m.request({
|
|
1011
966
|
method: "eth_accounts"
|
|
1012
|
-
}))[0],
|
|
1013
|
-
|
|
967
|
+
}))[0], u = await ot(
|
|
968
|
+
r,
|
|
1014
969
|
p,
|
|
1015
970
|
this.ctx.env,
|
|
1016
|
-
|
|
971
|
+
C.BTCb
|
|
1017
972
|
);
|
|
1018
973
|
if (this._feeAuth = {
|
|
1019
|
-
requiresAuth:
|
|
1020
|
-
isAuthorized:
|
|
1021
|
-
feeInSatoshis:
|
|
1022
|
-
feeFormatted:
|
|
1023
|
-
expirationDate:
|
|
1024
|
-
},
|
|
974
|
+
requiresAuth: u.requiresAuth,
|
|
975
|
+
isAuthorized: u.hasValidSignature,
|
|
976
|
+
feeInSatoshis: u.feeInSatoshis,
|
|
977
|
+
feeFormatted: u.feeFormatted,
|
|
978
|
+
expirationDate: u.expirationDate
|
|
979
|
+
}, u.requiresAuth && !u.hasValidSignature) {
|
|
1025
980
|
this.updateStatus(s.NEEDS_FEE_AUTHORIZATION), this.emitProgress({
|
|
1026
981
|
status: s.NEEDS_FEE_AUTHORIZATION,
|
|
1027
982
|
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
@@ -1048,19 +1003,19 @@ class ie extends x {
|
|
|
1048
1003
|
), !this._feeAuth.feeInSatoshis)
|
|
1049
1004
|
throw h.missingParameter("feeInSatoshis");
|
|
1050
1005
|
return this.act(async () => {
|
|
1051
|
-
const t =
|
|
1006
|
+
const t = f(this.params.sourceChain), e = await this.ctx.getProvider("evm");
|
|
1052
1007
|
if (!e)
|
|
1053
1008
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
1054
|
-
const
|
|
1009
|
+
const m = (await e.request({
|
|
1055
1010
|
method: "eth_accounts"
|
|
1056
1011
|
}))[0];
|
|
1057
|
-
await
|
|
1012
|
+
await ct({
|
|
1058
1013
|
chainId: t,
|
|
1059
|
-
account:
|
|
1014
|
+
account: m,
|
|
1060
1015
|
feeInSatoshis: this._feeAuth.feeInSatoshis,
|
|
1061
1016
|
provider: e,
|
|
1062
1017
|
env: this.ctx.env,
|
|
1063
|
-
token:
|
|
1018
|
+
token: C.BTCb
|
|
1064
1019
|
}), this._feeAuth.isAuthorized = !0, this.emitProgress({
|
|
1065
1020
|
status: s.READY,
|
|
1066
1021
|
steps: { burning: i.IDLE, releasing: i.IDLE }
|
|
@@ -1072,51 +1027,51 @@ class ie extends x {
|
|
|
1072
1027
|
const t = await this.ctx.getProvider("evm");
|
|
1073
1028
|
if (!t)
|
|
1074
1029
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
1075
|
-
const
|
|
1030
|
+
const r = (await t.request({
|
|
1076
1031
|
method: "eth_accounts"
|
|
1077
1032
|
}))[0];
|
|
1078
|
-
if (!
|
|
1033
|
+
if (!r)
|
|
1079
1034
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
1080
|
-
const
|
|
1035
|
+
const m = f(this.params.sourceChain), c = this.params.assetOut === l.BTCb;
|
|
1081
1036
|
this.emitProgress({
|
|
1082
1037
|
status: s.READY,
|
|
1083
1038
|
steps: { burning: i.PENDING, releasing: i.IDLE }
|
|
1084
1039
|
});
|
|
1085
|
-
const p = await
|
|
1040
|
+
const p = await at({
|
|
1086
1041
|
provider: t,
|
|
1087
|
-
account:
|
|
1042
|
+
account: c ? this._recipient : r,
|
|
1088
1043
|
amount: this._amount,
|
|
1089
|
-
btcAddress:
|
|
1090
|
-
chainId:
|
|
1044
|
+
btcAddress: c ? void 0 : this._recipient,
|
|
1045
|
+
chainId: m,
|
|
1091
1046
|
env: this.ctx.env,
|
|
1092
|
-
tokenIn:
|
|
1093
|
-
tokenOut:
|
|
1047
|
+
tokenIn: C.LBTC,
|
|
1048
|
+
tokenOut: c ? C.BTCb : void 0
|
|
1094
1049
|
});
|
|
1095
1050
|
return this._txHash = p, this.emitProgress({
|
|
1096
1051
|
status: s.COMPLETED,
|
|
1097
1052
|
steps: {
|
|
1098
1053
|
burning: i.COMPLETE,
|
|
1099
|
-
releasing:
|
|
1054
|
+
releasing: c ? i.COMPLETE : i.PENDING
|
|
1100
1055
|
}
|
|
1101
1056
|
}), this.emitCompleted(), { txHash: p };
|
|
1102
1057
|
}, s.COMPLETED);
|
|
1103
1058
|
}
|
|
1104
1059
|
get prepareSchema() {
|
|
1105
1060
|
const t = this.params.assetOut === l.BTC ? se : ae;
|
|
1106
|
-
return
|
|
1061
|
+
return O({
|
|
1107
1062
|
amount: b,
|
|
1108
1063
|
recipient: t.recipientSchema
|
|
1109
1064
|
});
|
|
1110
1065
|
}
|
|
1111
1066
|
}
|
|
1112
|
-
function ne(
|
|
1113
|
-
return new ie(
|
|
1067
|
+
function ne(n, a) {
|
|
1068
|
+
return new ie(n, a);
|
|
1114
1069
|
}
|
|
1115
1070
|
const ht = {
|
|
1116
1071
|
routes: [
|
|
1117
1072
|
// Veda - Ethereum, Base, BSC, Corn
|
|
1118
1073
|
{
|
|
1119
|
-
sourceChains: [
|
|
1074
|
+
sourceChains: [A.ETHEREUM, A.BASE, A.BSC, A.CORN],
|
|
1120
1075
|
protocols: [S.Veda],
|
|
1121
1076
|
envs: [o.prod]
|
|
1122
1077
|
}
|
|
@@ -1125,9 +1080,9 @@ const ht = {
|
|
|
1125
1080
|
class re extends x {
|
|
1126
1081
|
constructor(t, e) {
|
|
1127
1082
|
super(s.IDLE);
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1083
|
+
d(this, "_txHash");
|
|
1084
|
+
d(this, "_account");
|
|
1085
|
+
d(this, "_chainId");
|
|
1131
1086
|
this.ctx = t, this.params = e;
|
|
1132
1087
|
}
|
|
1133
1088
|
get txHash() {
|
|
@@ -1139,12 +1094,12 @@ class re extends x {
|
|
|
1139
1094
|
const t = await this.ctx.getProvider("evm");
|
|
1140
1095
|
if (!t)
|
|
1141
1096
|
throw h.providerMissing(this.params.chain, "evm");
|
|
1142
|
-
const
|
|
1097
|
+
const r = (await t.request({
|
|
1143
1098
|
method: "eth_accounts"
|
|
1144
1099
|
}))[0];
|
|
1145
|
-
if (!
|
|
1100
|
+
if (!r)
|
|
1146
1101
|
throw h.providerMissing(this.params.chain, "evm");
|
|
1147
|
-
if (this._account =
|
|
1102
|
+
if (this._account = r, this._chainId = f(this.params.chain), !j(this._chainId))
|
|
1148
1103
|
throw new h(
|
|
1149
1104
|
H.PROTOCOL_NOT_SUPPORTED,
|
|
1150
1105
|
`Chain ${this.params.chain} does not support Veda vault withdrawals`,
|
|
@@ -1181,7 +1136,7 @@ class re extends x {
|
|
|
1181
1136
|
}
|
|
1182
1137
|
validateProtocol(t) {
|
|
1183
1138
|
if (!ht.routes.some(
|
|
1184
|
-
(
|
|
1139
|
+
(r) => r.protocols.includes(t) && r.envs.includes(this.ctx.env)
|
|
1185
1140
|
))
|
|
1186
1141
|
throw h.invalidParameter(
|
|
1187
1142
|
"protocol",
|
|
@@ -1192,12 +1147,12 @@ class re extends x {
|
|
|
1192
1147
|
class oe extends x {
|
|
1193
1148
|
constructor(t, e) {
|
|
1194
1149
|
super(s.IDLE);
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1150
|
+
d(this, "_amount");
|
|
1151
|
+
d(this, "_protocol");
|
|
1152
|
+
d(this, "_needsApproval", !1);
|
|
1153
|
+
d(this, "_txHash");
|
|
1154
|
+
d(this, "_account");
|
|
1155
|
+
d(this, "_chainId");
|
|
1201
1156
|
this.ctx = t, this.params = e;
|
|
1202
1157
|
}
|
|
1203
1158
|
get amount() {
|
|
@@ -1214,57 +1169,57 @@ class oe extends x {
|
|
|
1214
1169
|
}
|
|
1215
1170
|
async prepare(t) {
|
|
1216
1171
|
return this.assertStatus(s.IDLE, "prepare"), this.act(async () => {
|
|
1217
|
-
const e =
|
|
1172
|
+
const e = B(this.prepareSchema, t);
|
|
1218
1173
|
this._amount = e.amount, this._protocol = this.params.protocol, this.validateProtocol(this.params.protocol);
|
|
1219
|
-
const
|
|
1220
|
-
if (!
|
|
1174
|
+
const r = await this.ctx.getProvider("evm");
|
|
1175
|
+
if (!r)
|
|
1221
1176
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
1222
|
-
const
|
|
1177
|
+
const c = (await r.request({
|
|
1223
1178
|
method: "eth_accounts"
|
|
1224
1179
|
}))[0];
|
|
1225
|
-
if (!
|
|
1180
|
+
if (!c)
|
|
1226
1181
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
1227
|
-
if (this._account =
|
|
1182
|
+
if (this._account = c, this._chainId = f(this.params.sourceChain), !j(this._chainId))
|
|
1228
1183
|
throw new h(
|
|
1229
1184
|
H.PROTOCOL_NOT_SUPPORTED,
|
|
1230
1185
|
`Chain ${this.params.sourceChain} does not support Veda vault withdrawals`,
|
|
1231
1186
|
{ chain: this.params.sourceChain, protocol: this._protocol }
|
|
1232
1187
|
);
|
|
1233
|
-
const p =
|
|
1188
|
+
const p = q, u = N({ chainId: this._chainId }), _ = new P(e.amount), g = await u.readContract({
|
|
1234
1189
|
address: p.lensContract.address,
|
|
1235
1190
|
abi: p.lensContract.abi,
|
|
1236
1191
|
functionName: "balanceOf",
|
|
1237
|
-
args: [
|
|
1192
|
+
args: [c, p.vaultContract.address]
|
|
1238
1193
|
}), v = y(
|
|
1239
1194
|
String(g),
|
|
1240
1195
|
p.decimals
|
|
1241
1196
|
);
|
|
1242
|
-
let
|
|
1197
|
+
let E = v;
|
|
1243
1198
|
if (k(this._chainId)) {
|
|
1244
|
-
const L = await
|
|
1245
|
-
address:
|
|
1246
|
-
abi:
|
|
1199
|
+
const L = await u.readContract({
|
|
1200
|
+
address: D.contracts[this._chainId],
|
|
1201
|
+
abi: D.abi,
|
|
1247
1202
|
functionName: "balanceOf",
|
|
1248
|
-
args: [
|
|
1203
|
+
args: [c]
|
|
1249
1204
|
}), V = y(
|
|
1250
1205
|
String(L),
|
|
1251
1206
|
p.decimals
|
|
1252
1207
|
);
|
|
1253
|
-
|
|
1208
|
+
E = v.plus(V);
|
|
1254
1209
|
}
|
|
1255
|
-
if (_.isGreaterThan(
|
|
1210
|
+
if (_.isGreaterThan(E))
|
|
1256
1211
|
throw new h(
|
|
1257
1212
|
H.INSUFFICIENT_SHARES,
|
|
1258
|
-
`Insufficient vault shares. Requested: ${_.toFixed()}, Available: ${
|
|
1259
|
-
{ requested: _.toFixed(), available:
|
|
1213
|
+
`Insufficient vault shares. Requested: ${_.toFixed()}, Available: ${E.toFixed()}`,
|
|
1214
|
+
{ requested: _.toFixed(), available: E.toFixed() }
|
|
1260
1215
|
);
|
|
1261
|
-
const
|
|
1216
|
+
const w = await u.readContract({
|
|
1262
1217
|
address: p.vaultContract.address,
|
|
1263
1218
|
abi: p.vaultContract.abi,
|
|
1264
1219
|
functionName: "allowance",
|
|
1265
|
-
args: [
|
|
1220
|
+
args: [c, p.withdrawQueueContracts[this._chainId].address]
|
|
1266
1221
|
}), R = y(
|
|
1267
|
-
String(
|
|
1222
|
+
String(w),
|
|
1268
1223
|
p.decimals
|
|
1269
1224
|
);
|
|
1270
1225
|
this._needsApproval = _.isGreaterThan(R), this._needsApproval ? (this.emitProgress({
|
|
@@ -1301,58 +1256,58 @@ class oe extends x {
|
|
|
1301
1256
|
const t = await this.ctx.getProvider("evm");
|
|
1302
1257
|
if (!t)
|
|
1303
1258
|
throw h.providerMissing(this.params.sourceChain, "evm");
|
|
1304
|
-
const e =
|
|
1259
|
+
const e = q, r = new P(this._amount), m = Z(Y(r, e.decimals)), c = N({ chainId: this._chainId }), p = W({
|
|
1305
1260
|
provider: t,
|
|
1306
1261
|
chainId: this._chainId
|
|
1307
|
-
}),
|
|
1262
|
+
}), u = this._chainId;
|
|
1308
1263
|
if (k(this._chainId)) {
|
|
1309
|
-
const v = await
|
|
1264
|
+
const v = await c.readContract({
|
|
1310
1265
|
address: e.lensContract.address,
|
|
1311
1266
|
abi: e.lensContract.abi,
|
|
1312
1267
|
functionName: "balanceOf",
|
|
1313
1268
|
args: [this._account, e.vaultContract.address]
|
|
1314
1269
|
});
|
|
1315
|
-
if (v <
|
|
1316
|
-
const
|
|
1317
|
-
address:
|
|
1318
|
-
abi:
|
|
1270
|
+
if (v < m) {
|
|
1271
|
+
const E = m - v, w = await c.readContract({
|
|
1272
|
+
address: D.contracts[this._chainId],
|
|
1273
|
+
abi: D.abi,
|
|
1319
1274
|
functionName: "maxWithdraw",
|
|
1320
1275
|
args: [this._account]
|
|
1321
1276
|
});
|
|
1322
|
-
if (
|
|
1277
|
+
if (w < E)
|
|
1323
1278
|
throw new h(
|
|
1324
1279
|
H.INSUFFICIENT_SHARES,
|
|
1325
|
-
`BTCe wrapper cannot cover the required unwrap. needed=${
|
|
1280
|
+
`BTCe wrapper cannot cover the required unwrap. needed=${E.toString()}, maxWithdraw=${w.toString()}.`,
|
|
1326
1281
|
{
|
|
1327
|
-
needed:
|
|
1328
|
-
maxWithdraw:
|
|
1282
|
+
needed: E.toString(),
|
|
1283
|
+
maxWithdraw: w.toString()
|
|
1329
1284
|
}
|
|
1330
1285
|
);
|
|
1331
|
-
const { request: R } = await
|
|
1286
|
+
const { request: R } = await c.simulateContract({
|
|
1332
1287
|
account: this._account,
|
|
1333
1288
|
chain: M[this._chainId],
|
|
1334
|
-
address:
|
|
1335
|
-
abi:
|
|
1289
|
+
address: D.contracts[this._chainId],
|
|
1290
|
+
abi: D.abi,
|
|
1336
1291
|
functionName: "withdraw",
|
|
1337
|
-
args: [
|
|
1292
|
+
args: [E, this._account, this._account]
|
|
1338
1293
|
}), L = await p.writeContract(R);
|
|
1339
1294
|
await F(
|
|
1340
|
-
|
|
1295
|
+
c,
|
|
1341
1296
|
L,
|
|
1342
1297
|
"BTCe unwrap"
|
|
1343
1298
|
);
|
|
1344
1299
|
}
|
|
1345
1300
|
}
|
|
1346
|
-
const { request: _ } = await
|
|
1301
|
+
const { request: _ } = await c.simulateContract({
|
|
1347
1302
|
account: this._account,
|
|
1348
1303
|
chain: M[this._chainId],
|
|
1349
1304
|
address: e.vaultContract.address,
|
|
1350
1305
|
abi: e.vaultContract.abi,
|
|
1351
1306
|
functionName: "approve",
|
|
1352
|
-
args: [e.withdrawQueueContracts[
|
|
1307
|
+
args: [e.withdrawQueueContracts[u].address, m]
|
|
1353
1308
|
}), g = await p.writeContract(_);
|
|
1354
1309
|
await F(
|
|
1355
|
-
|
|
1310
|
+
c,
|
|
1356
1311
|
g,
|
|
1357
1312
|
"vault share approval"
|
|
1358
1313
|
), this._needsApproval = !1, this.emitProgress({
|
|
@@ -1393,13 +1348,13 @@ class oe extends x {
|
|
|
1393
1348
|
}, s.COMPLETED);
|
|
1394
1349
|
}
|
|
1395
1350
|
get prepareSchema() {
|
|
1396
|
-
return
|
|
1351
|
+
return O({
|
|
1397
1352
|
amount: b
|
|
1398
1353
|
});
|
|
1399
1354
|
}
|
|
1400
1355
|
validateProtocol(t) {
|
|
1401
1356
|
if (!ht.routes.some(
|
|
1402
|
-
(
|
|
1357
|
+
(r) => r.protocols.includes(t) && r.envs.includes(this.ctx.env)
|
|
1403
1358
|
))
|
|
1404
1359
|
throw h.invalidParameter(
|
|
1405
1360
|
"protocol",
|
|
@@ -1407,15 +1362,15 @@ class oe extends x {
|
|
|
1407
1362
|
);
|
|
1408
1363
|
}
|
|
1409
1364
|
}
|
|
1410
|
-
function ce(
|
|
1411
|
-
return new oe(
|
|
1365
|
+
function ce(n, a) {
|
|
1366
|
+
return new oe(n, a);
|
|
1412
1367
|
}
|
|
1413
|
-
function he(
|
|
1414
|
-
return new re(
|
|
1368
|
+
function he(n, a) {
|
|
1369
|
+
return new re(n, a);
|
|
1415
1370
|
}
|
|
1416
1371
|
class ue {
|
|
1417
1372
|
constructor(a) {
|
|
1418
|
-
|
|
1373
|
+
d(this, "ctx");
|
|
1419
1374
|
this.ctx = St(a);
|
|
1420
1375
|
}
|
|
1421
1376
|
/**
|
|
@@ -1533,31 +1488,40 @@ class ue {
|
|
|
1533
1488
|
return he(this.ctx, a);
|
|
1534
1489
|
}
|
|
1535
1490
|
/**
|
|
1536
|
-
* Redeem
|
|
1491
|
+
* Redeem BTC.b to native BTC (cross-chain to Bitcoin)
|
|
1537
1492
|
*
|
|
1538
|
-
*
|
|
1539
|
-
*
|
|
1493
|
+
* Burns BTC.b on the EVM source chain and releases native BTC to a Bitcoin
|
|
1494
|
+
* recipient address. This is the inverse of BTC Deposit. The destination is
|
|
1495
|
+
* always the Bitcoin network — for LBTC → BTC.b on the same EVM chain, use
|
|
1496
|
+
* {@link unstake} with `assetOut: AssetId.BTCb`.
|
|
1540
1497
|
*
|
|
1541
1498
|
* @example
|
|
1542
1499
|
* ```typescript
|
|
1543
1500
|
* const redeem = evm.redeem({
|
|
1544
|
-
* assetIn: AssetId.
|
|
1545
|
-
* assetOut: AssetId.
|
|
1501
|
+
* assetIn: AssetId.BTCb,
|
|
1502
|
+
* assetOut: AssetId.BTC,
|
|
1546
1503
|
* sourceChain: Chain.AVALANCHE,
|
|
1504
|
+
* destChain: Chain.BITCOIN_MAINNET,
|
|
1505
|
+
* });
|
|
1506
|
+
*
|
|
1507
|
+
* await redeem.prepare({
|
|
1508
|
+
* amount: '0.1',
|
|
1509
|
+
* recipient: 'bc1q...',
|
|
1547
1510
|
* });
|
|
1511
|
+
* const { txHash } = await redeem.execute();
|
|
1548
1512
|
* ```
|
|
1549
1513
|
*/
|
|
1550
1514
|
redeem(a) {
|
|
1551
|
-
return
|
|
1515
|
+
return zt(this.ctx, a);
|
|
1552
1516
|
}
|
|
1553
1517
|
}
|
|
1554
|
-
function Se(
|
|
1555
|
-
return new ue(
|
|
1518
|
+
function Se(n) {
|
|
1519
|
+
return new ue(n);
|
|
1556
1520
|
}
|
|
1557
1521
|
export {
|
|
1558
1522
|
ue as EvmActions,
|
|
1559
1523
|
I as EvmDepositStatus,
|
|
1560
1524
|
Se as evmActions,
|
|
1561
|
-
|
|
1525
|
+
De as evmModule
|
|
1562
1526
|
};
|
|
1563
|
-
//# sourceMappingURL=EvmActions-
|
|
1527
|
+
//# sourceMappingURL=EvmActions-8VeTiWrl.js.map
|