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