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