@lombard.finance/sdk 2.1.2 → 2.1.3
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/README.md +98 -69
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +191 -163
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/web3Sdk/abi/STAKE_AND_BAKE.json +15 -0
- package/src/web3Sdk/abi/index.ts +2 -1
- package/src/web3Sdk/getStakeAndBakeFee/getStakeAndBakeFee.stories.tsx +64 -0
- package/src/web3Sdk/getStakeAndBakeFee/getStakeAndBakeFee.tsx +48 -0
- package/src/web3Sdk/getStakeAndBakeFee/index.ts +1 -0
- package/src/web3Sdk/index.ts +1 -0
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ const { getDepositBtcAddress } = require('@lombard.finance/sdk');
|
|
|
53
53
|
- [getBasculeDepositStatus](#getBasculeDepositStatus)
|
|
54
54
|
- [getLBTCTotalSupply](#getLBTCTotalSupply)
|
|
55
55
|
- [signStakeAndBake](#signStakeAndBake)
|
|
56
|
+
- [getStakeAndBakeFee](#getStakeAndBakeFee)
|
|
56
57
|
|
|
57
58
|
#### getDepositBtcAddress
|
|
58
59
|
|
|
@@ -129,10 +130,10 @@ Returns all deposits for a given address.
|
|
|
129
130
|
|
|
130
131
|
Parameters:
|
|
131
132
|
|
|
132
|
-
| name
|
|
133
|
-
|
|
134
|
-
| `address` | `string` | The EVM address to get deposits for
|
|
135
|
-
| `env`
|
|
133
|
+
| name | type | description |
|
|
134
|
+
| --------- | -------- | --------------------------------------- |
|
|
135
|
+
| `address` | `string` | The EVM address to get deposits for |
|
|
136
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
136
137
|
|
|
137
138
|
Usage
|
|
138
139
|
|
|
@@ -152,11 +153,11 @@ Returns the exchange rate for LBTC.
|
|
|
152
153
|
|
|
153
154
|
Parameters:
|
|
154
155
|
|
|
155
|
-
| name
|
|
156
|
-
|
|
156
|
+
| name | type | description |
|
|
157
|
+
| --------- | ---------- | ------------------------------------------------------ |
|
|
157
158
|
| `chainId` | `TChainId` | The chain id of the asset to get the exchange rate for |
|
|
158
|
-
| `amount`
|
|
159
|
-
| `env`
|
|
159
|
+
| `amount` | `number` | The amount of the asset to get the exchange rate for |
|
|
160
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
160
161
|
|
|
161
162
|
Usage
|
|
162
163
|
|
|
@@ -178,11 +179,11 @@ Signing is necessary for the generation of the deposit address.
|
|
|
178
179
|
|
|
179
180
|
Parameters:
|
|
180
181
|
|
|
181
|
-
| name
|
|
182
|
-
|
|
182
|
+
| name | type | description |
|
|
183
|
+
| ---------- | ------------------ | ------------------------------ |
|
|
183
184
|
| `provider` | `IEIP1193Provider` | The EIP-1193 provider instance |
|
|
184
|
-
| `account`
|
|
185
|
-
| `chainId`
|
|
185
|
+
| `account` | `string` | Current account address |
|
|
186
|
+
| `chainId` | `TChainId` | Current chain ID |
|
|
186
187
|
|
|
187
188
|
Usage
|
|
188
189
|
|
|
@@ -206,14 +207,14 @@ Claims LBTC.
|
|
|
206
207
|
|
|
207
208
|
Parameters:
|
|
208
209
|
|
|
209
|
-
| name
|
|
210
|
-
|
|
211
|
-
| `data`
|
|
212
|
-
| `proofSignature` | `string`
|
|
213
|
-
| `provider`
|
|
214
|
-
| `account`
|
|
215
|
-
| `chainId`
|
|
216
|
-
| `env`
|
|
210
|
+
| name | type | description |
|
|
211
|
+
| ---------------- | ------------------ | -------------------------------------------------------------------------------------- |
|
|
212
|
+
| `data` | `string` | Raw payload from deposit notarization. Can be obtained from the `getDepositsByAddress` |
|
|
213
|
+
| `proofSignature` | `string` | Signature from deposit notarization. Can be obtained from the `getDepositsByAddress` |
|
|
214
|
+
| `provider` | `IEIP1193Provider` | The EIP-1193 provider instance |
|
|
215
|
+
| `account` | `string` | Current account address |
|
|
216
|
+
| `chainId` | `TChainId` | Current chain ID |
|
|
217
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
217
218
|
|
|
218
219
|
Usage
|
|
219
220
|
|
|
@@ -241,14 +242,14 @@ Unstakes LBTC to the specified BTC address.
|
|
|
241
242
|
|
|
242
243
|
Parameters:
|
|
243
244
|
|
|
244
|
-
| name
|
|
245
|
-
|
|
246
|
-
| `btcAddress` | `string`
|
|
247
|
-
| `amount`
|
|
248
|
-
| `provider`
|
|
249
|
-
| `account`
|
|
250
|
-
| `chainId`
|
|
251
|
-
| `env`
|
|
245
|
+
| name | type | description |
|
|
246
|
+
| ------------ | ------------------ | ------------------------------------------- |
|
|
247
|
+
| `btcAddress` | `string` | The BTC address to send the unstaked BTC to |
|
|
248
|
+
| `amount` | `string` | The amount of LBTC to unstake |
|
|
249
|
+
| `provider` | `IEIP1193Provider` | The EIP-1193 provider instance |
|
|
250
|
+
| `account` | `string` | Current account address |
|
|
251
|
+
| `chainId` | `TChainId` | Current chain ID |
|
|
252
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
252
253
|
|
|
253
254
|
Usage
|
|
254
255
|
|
|
@@ -276,13 +277,13 @@ Check Deposit Status by hash id through Bascule
|
|
|
276
277
|
|
|
277
278
|
Parameters:
|
|
278
279
|
|
|
279
|
-
| name
|
|
280
|
-
|
|
281
|
-
| `txId`
|
|
282
|
-
| `provider` | `IEIP1193Provider` | The EIP-1193 provider instance
|
|
283
|
-
| `account`
|
|
284
|
-
| `chainId`
|
|
285
|
-
| `env`
|
|
280
|
+
| name | type | description |
|
|
281
|
+
| ---------- | ------------------ | ---------------------------------------------------------------------------------- |
|
|
282
|
+
| `txId` | `string` | Payload from deposit notarization. Can be obtained from the `getDepositsByAddress` |
|
|
283
|
+
| `provider` | `IEIP1193Provider` | The EIP-1193 provider instance |
|
|
284
|
+
| `account` | `string` | Current account address |
|
|
285
|
+
| `chainId` | `TChainId` | Current chain ID |
|
|
286
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
286
287
|
|
|
287
288
|
Usage
|
|
288
289
|
|
|
@@ -307,11 +308,11 @@ Get LBTC total supply
|
|
|
307
308
|
|
|
308
309
|
Parameters:
|
|
309
310
|
|
|
310
|
-
| name
|
|
311
|
-
|
|
312
|
-
| `rpcUrl`
|
|
313
|
-
| `chainId` | `TChainId` | Current chain ID
|
|
314
|
-
| `env`
|
|
311
|
+
| name | type | description |
|
|
312
|
+
| --------- | ---------- | --------------------------------------- |
|
|
313
|
+
| `rpcUrl` | `string` | Rpc url for the chain |
|
|
314
|
+
| `chainId` | `TChainId` | Current chain ID |
|
|
315
|
+
| `env` | `TEnv` | Environment (optional, default: 'prod') |
|
|
315
316
|
|
|
316
317
|
Usage
|
|
317
318
|
|
|
@@ -333,15 +334,15 @@ Sign Stake And Bake
|
|
|
333
334
|
|
|
334
335
|
## Parameters
|
|
335
336
|
|
|
336
|
-
| name
|
|
337
|
-
|
|
338
|
-
| `provider`
|
|
339
|
-
| `address`
|
|
340
|
-
| `chainId`
|
|
341
|
-
| `value`
|
|
342
|
-
| `expiry`
|
|
343
|
-
| `rpcUrl`
|
|
344
|
-
| `vaultKey`
|
|
337
|
+
| name | type | description |
|
|
338
|
+
| ---------- | ------------------- | ------------------------------------------------- |
|
|
339
|
+
| `provider` | `IProvider` | Provider instance to interact with the blockchain |
|
|
340
|
+
| `address` | `string` | The address to sign with (owner) |
|
|
341
|
+
| `chainId` | `TChainId` | Chain ID for the signature |
|
|
342
|
+
| `value` | `string` | The value to approve |
|
|
343
|
+
| `expiry` | `number` | Expiry date as a unix timestamp |
|
|
344
|
+
| `rpcUrl` | `string` (optional) | Optional RPC URL for the network |
|
|
345
|
+
| `vaultKey` | `string` | The key of the vault to authorize |
|
|
345
346
|
|
|
346
347
|
Usage
|
|
347
348
|
|
|
@@ -354,7 +355,7 @@ const { signature, signatureData } = await signStakeAndBake({
|
|
|
354
355
|
chainId,
|
|
355
356
|
value: toSatoshi(approvalValue.toString()).toString(),
|
|
356
357
|
expiry: permitExpiryTime,
|
|
357
|
-
vaultKey: selectedVault.key
|
|
358
|
+
vaultKey: selectedVault.key,
|
|
358
359
|
});
|
|
359
360
|
```
|
|
360
361
|
|
|
@@ -366,19 +367,22 @@ Store stake and bake signature
|
|
|
366
367
|
|
|
367
368
|
## Parameters
|
|
368
369
|
|
|
369
|
-
| name
|
|
370
|
-
|
|
371
|
-
| `env`
|
|
372
|
-
| `signature`
|
|
373
|
-
| `typedData`
|
|
370
|
+
| name | type | description |
|
|
371
|
+
| ----------- | -------- | --------------------------------------- |
|
|
372
|
+
| `env` | `TEnv` | Environment (e.g., 'prod', 'dev', etc.) |
|
|
373
|
+
| `signature` | `string` | The generated signature |
|
|
374
|
+
| `typedData` | `string` | JSON typed data used for the signature |
|
|
374
375
|
|
|
375
376
|
Usage
|
|
376
377
|
|
|
377
378
|
```typescript
|
|
378
379
|
import { storeStakeAndBakeSignature } from '@lombard.finance/sdk';
|
|
379
380
|
|
|
380
|
-
const status = await storeStakeAndBakeSignature({
|
|
381
|
-
|
|
381
|
+
const status = await storeStakeAndBakeSignature({
|
|
382
|
+
signature,
|
|
383
|
+
signatureData,
|
|
384
|
+
env: 'prod',
|
|
385
|
+
});
|
|
382
386
|
```
|
|
383
387
|
|
|
384
388
|
#### getUserStakeAndBakeSignature
|
|
@@ -389,12 +393,11 @@ Get user's stake and bake signature from the API
|
|
|
389
393
|
|
|
390
394
|
## Parameters
|
|
391
395
|
|
|
392
|
-
| name
|
|
393
|
-
|
|
394
|
-
| `userDestinationAddress
|
|
395
|
-
| `chainId`
|
|
396
|
-
| `env`
|
|
397
|
-
|
|
396
|
+
| name | type | description |
|
|
397
|
+
| ------------------------ | -------- | --------------------------------------- |
|
|
398
|
+
| `userDestinationAddress` | `string` | The user's destination address |
|
|
399
|
+
| `chainId` | `string` | The chain ID |
|
|
400
|
+
| `env` | `TEnv` | Environment (e.g., 'prod', 'dev', etc.) |
|
|
398
401
|
|
|
399
402
|
Usage
|
|
400
403
|
|
|
@@ -404,7 +407,7 @@ import { getUserStakeAndBakeSignature } from '@lombard.finance/sdk';
|
|
|
404
407
|
const response = await getUserStakeAndBakeSignature({
|
|
405
408
|
userDestinationAddress: address,
|
|
406
409
|
chainId,
|
|
407
|
-
env: 'prod'
|
|
410
|
+
env: 'prod',
|
|
408
411
|
});
|
|
409
412
|
console.log(response);
|
|
410
413
|
```
|
|
@@ -415,10 +418,9 @@ console.log(response);
|
|
|
415
418
|
|
|
416
419
|
## Parameters
|
|
417
420
|
|
|
418
|
-
| name
|
|
419
|
-
|
|
420
|
-
| `chainId`
|
|
421
|
-
|
|
421
|
+
| name | type | description |
|
|
422
|
+
| --------- | -------- | ------------ |
|
|
423
|
+
| `chainId` | `string` | The chain ID |
|
|
422
424
|
|
|
423
425
|
Usage
|
|
424
426
|
|
|
@@ -428,4 +430,31 @@ import { getStakeAndBakeVaults } from '@lombard.finance/sdk';
|
|
|
428
430
|
const vaults = getStakeAndBakeVaults(1);
|
|
429
431
|
|
|
430
432
|
console.log(vaults);
|
|
431
|
-
```
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
#### getStakeAndBakeFee
|
|
436
|
+
|
|
437
|
+
`@returns Promise<string>` Promise that resolves stakeAndBake fee in satoshis
|
|
438
|
+
|
|
439
|
+
Get Stake and bake fee in satoshis
|
|
440
|
+
|
|
441
|
+
## Parameters
|
|
442
|
+
|
|
443
|
+
| name | type | description |
|
|
444
|
+
| -------------- | -------- | --------------------- |
|
|
445
|
+
| `vaultAddress` | `string` | The vault address |
|
|
446
|
+
| `chainId` | `string` | The chain ID |
|
|
447
|
+
| `rpcUrl` | `string` | Rpc url for the chain |
|
|
448
|
+
|
|
449
|
+
Usage
|
|
450
|
+
|
|
451
|
+
```typescript
|
|
452
|
+
import { getStakeAndBakeFee } from '@lombard.finance/sdk';
|
|
453
|
+
|
|
454
|
+
const response = await getStakeAndBakeFee({
|
|
455
|
+
chainId: OChainId.binanceSmartChain,
|
|
456
|
+
rpcUrl: 'https://rpc.ankr.com/bsc',
|
|
457
|
+
vaultAddress: '0xC8bbF6153D7Ba105f1399D992ebd32B0541996ef',
|
|
458
|
+
});
|
|
459
|
+
console.log(response);
|
|
460
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var ue=Object.defineProperty;var ye=(e,t,n)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _=(e,t,n)=>(ye(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("axios"),I=require("bignumber.js"),f=require("web3"),de=require("@bitcoin-js/tiny-secp256k1-asmjs"),x=require("bitcoinjs-lib");function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ce=le(de),l={prod:"prod",testnet:"testnet",stage:"stage"},i={ethereum:1,holesky:17e3,binanceSmartChain:56,binanceSmartChainTestnet:97,sepolia:11155111,base:8453,baseSepoliaTestnet:84532,berachainBartioTestnet:80084,corn:21e6,swell:1923},q=e=>e===l.prod?i.ethereum:i.holesky,z=e=>e===l.prod?i.binanceSmartChain:i.binanceSmartChainTestnet,J=e=>e===l.prod?i.base:i.baseSepoliaTestnet,k=l.prod,y="0x0000000000000000000000000000000000000000",me={baseApiUrl:"https://staging.prod.lombard.finance"},be={baseApiUrl:"https://gastald-testnet.prod.lombard.finance"},fe={baseApiUrl:"https://mainnet.prod.lombard.finance"},A=(e=k)=>{switch(e){case l.prod:return fe;case l.testnet:return be;default:return me}};function S(e){return typeof e=="string"?e:(n=>{var a;return((a=n==null?void 0:n.data)==null?void 0:a.message)&&typeof n.data.message=="string"})(e)?e.data.message:e instanceof Error?Te(e):ge(e)}function Te(e){return e.response?e.response.data.message:e.message}function ge(e){return e!=null&&e.message?e.message:"Unknown error"}const w={eth:"DESTINATION_BLOCKCHAIN_ETHEREUM",ethOld:"BLOCKCHAIN_ETHEREUM",base:"DESTINATION_BLOCKCHAIN_BASE",baseOld:"BLOCKCHAIN_BASE",bsc:"DESTINATION_BLOCKCHAIN_BSC",bscOld:"BLOCKCHAIN_BSC"};function P(e){switch(e){case i.ethereum:case i.holesky:case i.sepolia:return w.eth;case i.base:case i.baseSepoliaTestnet:return w.base;case i.binanceSmartChain:case i.binanceSmartChainTestnet:return w.bsc;default:throw new Error(`Unknown chain ID: ${e}`)}}const X="sanctioned_address",he="api/v1/address/generate",we="destination address is under sanctions";async function Ae({address:e,chainId:t,signature:n,eip712Data:a,env:s,referrerCode:r,partnerId:o,captchaToken:p,signatureData:u}){const{baseApiUrl:T}=A(s),c=P(t),g={to_address:e,to_address_signature:n,to_chain:c,partner_id:o,nonce:0,captcha:p,referrer_code:r,eip_712_data:a,sb_signature_data:u};try{const{data:m}=await v.post(he,g,{baseURL:T});return m.address}catch(m){const b=S(m);if(ve(b))return X;throw new Error(b)}}function ve(e){return!!e.includes(we)}const Se="api/v1/address";async function Ce({address:e,chainId:t,env:n,partnerId:a}){const s=await Y({address:e,chainId:t,env:n,partnerId:a}),r=Ee(s);if(!r)throw new Error("No address");return r.btc_address}function Ee(e){if(!e.length)return;const t=e.reduce((n,a)=>n.created_at<a.created_at?a:n,e[0]);return t.deprecated?void 0:t}async function Y({address:e,chainId:t,env:n,partnerId:a}){const{baseApiUrl:s}=A(n),r=P(t),o={to_address:e,to_blockchain:r,limit:1,offset:0,asc:!1,referralId:a},{data:p}=await v.get(Se,{baseURL:s,params:o});return(p==null?void 0:p.addresses)||[]}const De=8,O=10**De;function F(e){return+e/O}function U(e){return Math.floor(+e*O)}function Q(e,t=k){switch(e){case w.eth:case w.ethOld:return q(t);case w.base:case w.baseOld:return J(t);case w.bsc:case w.bscOld:return z(t);default:return i.ethereum}}var ee=(e=>(e.NOTARIZATION_STATUS_UNSPECIFIED="NOTARIZATION_STATUS_UNSPECIFIED",e.NOTARIZATION_STATUS_PENDING="NOTARIZATION_STATUS_PENDING",e.NOTARIZATION_STATUS_SUBMITTED="NOTARIZATION_STATUS_SUBMITTED",e.NOTARIZATION_STATUS_SESSION_APPROVED="NOTARIZATION_STATUS_SESSION_APPROVED",e.NOTARIZATION_STATUS_FAILED="NOTARIZATION_STATUS_FAILED",e))(ee||{}),te=(e=>(e.SESSION_STATE_UNSPECIFIED="SESSION_STATE_UNSPECIFIED",e.SESSION_STATE_PENDING="SESSION_STATE_PENDING",e.SESSION_STATE_COMPLETED="SESSION_STATE_COMPLETED",e.SESSION_STATE_EXPIRED="SESSION_STATE_EXPIRED",e))(te||{});async function _e({address:e,env:t}){const{baseApiUrl:n}=A(t),{data:a}=await v.get(`api/v1/address/outputs-v2/${e}`,{baseURL:n});return((a==null?void 0:a.outputs)??[]).map(Ie(t))}function Ie(e){return t=>({txid:t.txid,index:t.index??0,blockHeight:t.block_height?Number(t.block_height):void 0,blockTime:t.block_time?Number(t.block_time):void 0,value:new I(F(t.value)),address:t.address,chainId:Q(t.to_chain,e),claimedTxId:t.claim_tx,isClaimed:!!t.claim_tx,rawPayload:t.raw_payload,signature:t.proof,isRestricted:!!t.sanctioned,notarizationWaitDur:t.notarization_wait_dur?Number(t.notarization_wait_dur):void 0,payload:t.payload_hash,sessionId:t.session_id,notarizationStatus:t.notarization_status,sessionState:t.session_state})}const xe=2e-4;async function Me({env:e,chainId:t=i.ethereum,amount:n=1}){const{baseApiUrl:a}=A(e),s=P(t),{data:r}=await v.get(`api/v1/exchange/rate/${s}`,{baseURL:a,params:{amount:n}}),o=new I(xe).multipliedBy(O).toFixed();return{exchangeRate:+r.amount_out,minAmount:+o}}async function Re({address:e,chainId:t,env:n}){const{baseApiUrl:a}=A(n);try{const{data:s}=await v.get(`${a}/api/v1/claimer/get-user-signature`,{params:{user_destination_address:e,chain_id:t}});return{expirationDate:s==null?void 0:s.expiration_date,hasSignature:s==null?void 0:s.has_signature,isDelayed:s==null?void 0:s.is_delayed}}catch(s){const r=S(s);throw new Error(r)}}async function Ne({userDestinationAddress:e,chainId:t,env:n}){const{baseApiUrl:a}=A(n);try{const{data:s}=await v.get(`${a}/api/v1/claimer/get-user-stake-and-bake-signature`,{params:{userDestinationAddress:e,chainId:t.toString()}});return{userDestinationAddress:s.user_destination_address,signature:s.signature,expirationDate:s.expiration_date,depositAmount:s.deposit_amount,chainId:s.chain_id}}catch(s){const r=S(s);throw new Error(`Failed to get user stake and bake signature: ${r}`)}}async function Pe({signature:e,typedData:t,address:n,env:a}){const{baseApiUrl:s}=A(a);try{const{data:r}=await v.post(`${s}/api/v1/claimer/save-user-signature`,null,{params:{typed_data:t,signature:e,user_destination_address:n}});return r.status}catch(r){const o=S(r);throw new Error(o)}}async function Oe({signature:e,typedData:t,env:n}){const{baseApiUrl:a}=A(n);try{const{data:s}=await v.post(`${a}/api/v1/claimer/save-stake-and-bake-signature`,null,{params:{typed_data:t,signature:e}});return s.status}catch(s){const r=S(s);throw new Error(r)}}const N={[i.ethereum]:"https://rpc.ankr.com/eth",[i.holesky]:"https://rpc.ankr.com/eth_holesky",[i.sepolia]:"https://rpc.ankr.com/eth_sepolia",[i.base]:"https://rpc.ankr.com/base",[i.baseSepoliaTestnet]:"https://rpc.ankr.com/base_sepolia",[i.binanceSmartChain]:"https://bsc-dataseed.bnbchain.org",[i.binanceSmartChainTestnet]:"https://bsc-testnet-dataseed.bnbchain.org"};async function Be(e){const n=await(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"eth_maxPriorityFeePerGas",params:[]})})).json(),a=f.utils.hexToNumber(n==null?void 0:n.result);return new I(Number(a))}const ke=2,Fe=25e3;class B{constructor({chainId:t,rpcUrlConfig:n}){_(this,"chainId");_(this,"rpcConfig");this.chainId=t,this.rpcConfig={...N,...n}}getReadWeb3(){const t=this.getRpcUrl(),n=new f.Web3,a=new f.Web3.providers.HttpProvider(t);return n.setProvider(a),n}getRpcUrl(){var a;const{chainId:t}=this,n=(a=this.rpcConfig)==null?void 0:a[t];if(!n)throw console.error(`You might need to add the rpcConfig for the ${t} chain ID when creating the provider.`),new Error(`RPC URL for chainId ${t} not found`);return n}async getMaxFees(){const t=this.getReadWeb3(),n=this.getRpcUrl(),[a,s]=await Promise.all([t.eth.getBlock("latest"),Be(n)]);return!(a!=null&&a.baseFeePerGas)&&typeof(a==null?void 0:a.baseFeePerGas)!="bigint"?{}:{maxFeePerGas:+new I(a.baseFeePerGas.toString(10)).multipliedBy(ke).plus(s),maxPriorityFeePerGas:+s}}async getSafeGasPriceWei(){const t=await this.getReadWeb3().eth.getGasPrice();return new I(t.toString(10)).plus(Fe)}createContract(t,n){const a=this.getReadWeb3();return new a.eth.Contract(t,n)}}class D extends B{constructor({provider:n,account:a,chainId:s,rpcUrlConfig:r}){super({chainId:s,rpcUrlConfig:r});_(this,"web3");_(this,"account");_(this,"rpcConfig",N);this.web3=new f(n),this.account=a,this.chainId=s,this.rpcConfig={...N,...r}}async signMessage(n){const{account:a}=this,s=`0x${Buffer.from(n,"utf8").toString("hex")}`;return this.web3.currentProvider.request({method:"personal_sign",params:[s,a]})}async sendTransactionAsync(n,a,s){const{chainId:r,web3:o}=this,p=this.getReadWeb3(),{data:u,estimate:T=!1,estimateFee:c=!1,extendedGasLimit:g,gasLimit:m="0",value:b="0",gasLimitMultiplier:M=1}=s;let{nonce:E}=s;E||(E=await p.eth.getTransactionCount(n)),console.log(`Nonce: ${E}`);const d={from:n,to:a,value:f.utils.numberToHex(b),data:u,nonce:E,chainId:f.utils.numberToHex(r)};if(T)try{const h=await p.eth.estimateGas(d),R=Math.round(Number(h)*M);g?d.gas=f.utils.numberToHex(R+g):d.gas=f.utils.numberToHex(R)}catch(h){throw new Error(h.message??"Failed to estimate gas limit for transaction.")}else d.gas=f.utils.numberToHex(m);const{maxFeePerGas:H,maxPriorityFeePerGas:$}=c?await this.getMaxFees().catch(()=>s):s;if($!==void 0&&(d.maxPriorityFeePerGas=f.utils.numberToHex($)),H!==void 0&&(d.maxFeePerGas=f.utils.numberToHex(H)),!d.maxFeePerGas&&!d.maxPriorityFeePerGas){const h=await this.getSafeGasPriceWei();d.gasPrice=h.toString(10)}if(!d.maxFeePerGas&&!d.maxPriorityFeePerGas){const h=await this.getSafeGasPriceWei();d.gasPrice=h.toString(10)}return console.log("Sending transaction via Web3: ",d),new Promise((h,R)=>{const K=o.eth.sendTransaction(d);K.once("transactionHash",async Z=>{console.log(`Just signed transaction has is: ${Z}`),h({receiptPromise:K,transactionHash:Z})}).catch(R)})}createContract(n,a){return new this.web3.eth.Contract(n,a)}}function L(e){switch(e){case i.ethereum:return 1.3;case i.holesky:case i.sepolia:return 1.5;default:return 1.3}}function W(e){return Object.values(i).includes(e)}const Ue={[i.holesky]:"0xED7bfd5C1790576105Af4649817f6d35A75CD818",[i.ethereum]:y,[i.binanceSmartChainTestnet]:"0x731eFa688F3679688cf60A3993b8658138953ED6",[i.binanceSmartChain]:y,[i.sepolia]:"0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",[i.base]:y,[i.baseSepoliaTestnet]:"0x731eFa688F3679688cf60A3993b8658138953ED6",[i.berachainBartioTestnet]:"0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",[i.corn]:y,[i.swell]:y},Le={[i.holesky]:"0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",[i.ethereum]:y,[i.binanceSmartChainTestnet]:"0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",[i.binanceSmartChain]:y,[i.sepolia]:"0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",[i.base]:y,[i.baseSepoliaTestnet]:y,[i.berachainBartioTestnet]:"0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",[i.corn]:y,[i.swell]:y},We={[i.ethereum]:"0x8236a87084f8b84306f72007f36f2618a5634494",[i.holesky]:y,[i.sepolia]:y,[i.binanceSmartChainTestnet]:y,[i.binanceSmartChain]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[i.base]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[i.baseSepoliaTestnet]:y,[i.berachainBartioTestnet]:y,[i.corn]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[i.swell]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1"};function G(e=k){switch(e){case l.prod:return We;case l.testnet:return Le;default:return Ue}}const Ge=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],Ve=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"uint256",name:"dustLimit",type:"uint256"}],name:"AmountBelowDustLimit",type:"error"},{inputs:[{internalType:"uint256",name:"fee",type:"uint256"}],name:"AmountLessThanCommission",type:"error"},{inputs:[],name:"ECDSAInvalidSignature",type:"error"},{inputs:[{internalType:"uint256",name:"length",type:"uint256"}],name:"ECDSAInvalidSignatureLength",type:"error"},{inputs:[{internalType:"bytes32",name:"s",type:"bytes32"}],name:"ECDSAInvalidSignatureS",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"allowance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientAllowance",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientBalance",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC20InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC20InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC20InvalidSender",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"}],name:"ERC20InvalidSpender",type:"error"},{inputs:[{internalType:"uint256",name:"deadline",type:"uint256"}],name:"ERC2612ExpiredSignature",type:"error"},{inputs:[{internalType:"address",name:"signer",type:"address"},{internalType:"address",name:"owner",type:"address"}],name:"ERC2612InvalidSigner",type:"error"},{inputs:[],name:"EnforcedPause",type:"error"},{inputs:[],name:"ExpectedPause",type:"error"},{inputs:[],name:"FeeGreaterThanAmount",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"uint256",name:"currentNonce",type:"uint256"}],name:"InvalidAccountNonce",type:"error"},{inputs:[],name:"InvalidDustFeeRate",type:"error"},{inputs:[],name:"InvalidInitialization",type:"error"},{inputs:[],name:"InvalidInputLength",type:"error"},{inputs:[],name:"InvalidUserSignature",type:"error"},{inputs:[],name:"KnownDestination",type:"error"},{inputs:[],name:"NotInitializing",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[],name:"PayloadAlreadyUsed",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[],name:"ScriptPubkeyUnsupported",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"UnauthorizedAccount",type:"error"},{inputs:[{internalType:"bytes4",name:"action",type:"bytes4"}],name:"UnexpectedAction",type:"error"},{inputs:[],name:"UnknownDestination",type:"error"},{inputs:[{internalType:"uint256",name:"fromChainId",type:"uint256"},{internalType:"address",name:"fromContract",type:"address"}],name:"UnknownOriginContract",type:"error"},{inputs:[{internalType:"uint256",name:"expiry",type:"uint256"}],name:"UserSignatureExpired",type:"error"},{inputs:[],name:"WithdrawalsDisabled",type:"error"},{inputs:[],name:"WrongChainId",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{inputs:[],name:"ZeroAmount",type:"error"},{inputs:[],name:"ZeroChainId",type:"error"},{inputs:[],name:"ZeroContractHash",type:"error"},{inputs:[],name:"ZeroFee",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"prevVal",type:"address"},{indexed:!0,internalType:"address",name:"newVal",type:"address"}],name:"BasculeChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"prevVal",type:"address"},{indexed:!0,internalType:"address",name:"newVal",type:"address"}],name:"BridgeChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint64",name:"prevValue",type:"uint64"},{indexed:!0,internalType:"uint64",name:"newValue",type:"uint64"}],name:"BurnCommissionChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"claimer",type:"address"},{indexed:!1,internalType:"bool",name:"isClaimer",type:"bool"}],name:"ClaimerUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"prevVal",type:"address"},{indexed:!0,internalType:"address",name:"newVal",type:"address"}],name:"ConsortiumChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oldRate",type:"uint256"},{indexed:!0,internalType:"uint256",name:"newRate",type:"uint256"}],name:"DustFeeRateChanged",type:"event"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oldFee",type:"uint256"},{indexed:!0,internalType:"uint256",name:"newFee",type:"uint256"}],name:"FeeChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"fee",type:"uint256"},{indexed:!1,internalType:"bytes",name:"userSignature",type:"bytes"}],name:"FeeCharged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"version",type:"uint64"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"recipient",type:"address"},{indexed:!0,internalType:"bytes32",name:"payloadHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"payload",type:"bytes"}],name:"MintProofConsumed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"minter",type:"address"},{indexed:!1,internalType:"bool",name:"isMinter",type:"bool"}],name:"MinterUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"string",name:"name",type:"string"},{indexed:!1,internalType:"string",name:"symbol",type:"string"}],name:"NameAndSymbolChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferStarted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousPauser",type:"address"},{indexed:!0,internalType:"address",name:"newPauser",type:"address"}],name:"PauserRoleTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"prevValue",type:"address"},{indexed:!0,internalType:"address",name:"newValue",type:"address"}],name:"TreasuryAddressChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"fromAddress",type:"address"},{indexed:!1,internalType:"bytes",name:"scriptPubKey",type:"bytes"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"UnstakeRequest",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"",type:"bool"}],name:"WithdrawalsEnabled",type:"event"},{inputs:[],name:"Bascule",outputs:[{internalType:"contract IBascule",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"acceptOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newClaimer",type:"address"}],name:"addClaimer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newMinter",type:"address"}],name:"addMinter",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address[]",name:"to",type:"address[]"},{internalType:"uint256[]",name:"amount",type:"uint256[]"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes[]",name:"payload",type:"bytes[]"},{internalType:"bytes[]",name:"proof",type:"bytes[]"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes[]",name:"mintPayload",type:"bytes[]"},{internalType:"bytes[]",name:"proof",type:"bytes[]"},{internalType:"bytes[]",name:"feePayload",type:"bytes[]"},{internalType:"bytes[]",name:"userSignature",type:"bytes[]"}],name:"batchMintWithFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"scriptPubkey",type:"bytes"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"calcUnstakeRequestAmount",outputs:[{internalType:"uint256",name:"amountAfterFee",type:"uint256"},{internalType:"bool",name:"isAboveDust",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newVal",type:"address"}],name:"changeBascule",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newBridge",type:"address"}],name:"changeBridge",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint64",name:"newValue",type:"uint64"}],name:"changeBurnCommission",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newVal",type:"address"}],name:"changeConsortium",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newRate",type:"uint256"}],name:"changeDustFeeRate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"string",name:"name_",type:"string"},{internalType:"string",name:"symbol_",type:"string"}],name:"changeNameAndSymbol",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newValue",type:"address"}],name:"changeTreasuryAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"consortium",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBurnCommission",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDustFeeRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMintFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getTreasury",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"consortium_",type:"address"},{internalType:"uint64",name:"burnCommission_",type:"uint64"},{internalType:"address",name:"owner_",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"claimer",type:"address"}],name:"isClaimer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"minter",type:"address"}],name:"isMinter",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"payload",type:"bytes"},{internalType:"bytes",name:"proof",type:"bytes"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"mintPayload",type:"bytes"},{internalType:"bytes",name:"proof",type:"bytes"},{internalType:"bytes",name:"feePayload",type:"bytes"},{internalType:"bytes",name:"userSignature",type:"bytes"}],name:"mintWithFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"pauser",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pendingOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"scriptPubkey",type:"bytes"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"reinitialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oldClaimer",type:"address"}],name:"removeClaimer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oldMinter",type:"address"}],name:"removeMinter",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"fee",type:"uint256"}],name:"setMintFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"toggleWithdrawals",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newPauser",type:"address"}],name:"transferPauserRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"fromChain",type:"uint256"},{internalType:"address",name:"fromContract",type:"address"},{internalType:"uint256",name:"toChain",type:"uint256"},{internalType:"address",name:"toContract",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint64",name:"amount",type:"uint64"},{internalType:"bytes32",name:"uniqueActionData",type:"bytes32"}],internalType:"struct Actions.DepositBridgeAction",name:"action",type:"tuple"},{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"bytes",name:"",type:"bytes"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"}],He=[{inputs:[{internalType:"address",name:"aDefaultAdmin",type:"address"},{internalType:"address",name:"aPauser",type:"address"},{internalType:"address",name:"aDepositReporter",type:"address"},{internalType:"address",name:"aWithdrawalValidator",type:"address"},{internalType:"uint256",name:"aMaxDeposits",type:"uint256"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccessControlBadConfirmation",type:"error"},{inputs:[{internalType:"uint48",name:"schedule",type:"uint48"}],name:"AccessControlEnforcedDefaultAdminDelay",type:"error"},{inputs:[],name:"AccessControlEnforcedDefaultAdminRules",type:"error"},{inputs:[{internalType:"address",name:"defaultAdmin",type:"address"}],name:"AccessControlInvalidDefaultAdmin",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"bytes32",name:"neededRole",type:"bytes32"}],name:"AccessControlUnauthorizedAccount",type:"error"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"}],name:"AlreadyReported",type:"error"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"},{internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"AlreadyWithdrawn",type:"error"},{inputs:[],name:"BadDepositReport",type:"error"},{inputs:[],name:"EnforcedPause",type:"error"},{inputs:[],name:"ExpectedPause",type:"error"},{inputs:[{internalType:"uint8",name:"bits",type:"uint8"},{internalType:"uint256",name:"value",type:"uint256"}],name:"SafeCastOverflowedUintDowncast",type:"error"},{inputs:[],name:"SameValidationThreshold",type:"error"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"},{internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"WithdrawalFailedValidation",type:"error"},{anonymous:!1,inputs:[],name:"DefaultAdminDelayChangeCanceled",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint48",name:"newDelay",type:"uint48"},{indexed:!1,internalType:"uint48",name:"effectSchedule",type:"uint48"}],name:"DefaultAdminDelayChangeScheduled",type:"event"},{anonymous:!1,inputs:[],name:"DefaultAdminTransferCanceled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newAdmin",type:"address"},{indexed:!1,internalType:"uint48",name:"acceptSchedule",type:"uint48"}],name:"DefaultAdminTransferScheduled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"reportId",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"numDeposits",type:"uint256"}],name:"DepositsReported",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"numDeposits",type:"uint256"}],name:"MaxDepositsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"previousAdminRole",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"newAdminRole",type:"bytes32"}],name:"RoleAdminChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleGranted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleRevoked",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"oldThreshold",type:"uint256"},{indexed:!1,internalType:"uint256",name:"newThreshold",type:"uint256"}],name:"UpdateValidateThreshold",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bytes32",name:"depositID",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"WithdrawalNotValidated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bytes32",name:"depositID",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"WithdrawalValidated",type:"event"},{inputs:[],name:"DEFAULT_ADMIN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"DEPOSIT_REPORTER_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"PAUSER_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"VALIDATION_GUARDIAN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"WITHDRAWAL_VALIDATOR_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"acceptDefaultAdminTransfer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newAdmin",type:"address"}],name:"beginDefaultAdminTransfer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"cancelDefaultAdminTransfer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"newDelay",type:"uint48"}],name:"changeDefaultAdminDelay",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"defaultAdmin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"defaultAdminDelay",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[],name:"defaultAdminDelayIncreaseWait",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"}],name:"depositHistory",outputs:[{internalType:"enum Bascule.DepositState",name:"status",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"}],name:"getRoleAdmin",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"grantRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"hasRole",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxDeposits",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"pendingDefaultAdmin",outputs:[{internalType:"address",name:"newAdmin",type:"address"},{internalType:"uint48",name:"schedule",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[],name:"pendingDefaultAdminDelay",outputs:[{internalType:"uint48",name:"newDelay",type:"uint48"},{internalType:"uint48",name:"schedule",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"renounceRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"reportId",type:"bytes32"},{internalType:"bytes32[]",name:"depositIDs",type:"bytes32[]"}],name:"reportDeposits",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"revokeRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"rollbackDefaultAdminDelay",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"aMaxDeposits",type:"uint256"}],name:"setMaxDeposits",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newThreshold",type:"uint256"}],name:"updateValidateThreshold",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"validateThreshold",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"},{internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"validateWithdrawal",outputs:[],stateMutability:"nonpayable",type:"function"}];function $e(e){switch(e){case"LBTC":return Ve;default:return Ge}}function C(e,t){const n=G(t),{chainId:a}=e;if(!W(a))throw new Error(`This chain ${a} is not supported`);const s=n[a];if(!s)throw new Error(`Token address for chain ${a} is not defined`);const r=$e("LBTC"),o=e.createContract(r,s);return o.options.address||(o.options.address=s),o}function Ke({spender:e,amount:t,env:n,...a}){const s=new D(a),r=C(s,n),o=U(t),p=r.methods.approve(e,o);return s.sendTransactionAsync(s.account,r.options.address,{data:p.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:L(s.chainId)})}const Ze="insufficient funds",je="Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.",j=e=>e.startsWith("0x")?e:"0x"+e;async function qe({data:e,proofSignature:t,env:n,...a}){const s=new D(a),r=C(s,n),o=r.methods.mint(j(e),j(t));try{return await s.sendTransactionAsync(s.account,r.options.address,{data:o.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:L(s.chainId)})}catch(p){console.log("error",p);const u=S(p);throw u.includes(Ze)?new Error(je):new Error(u)}}function ze(e,t){if(!t)throw new Error("The address for bascule module is not defined");const n=e.createContract(He,t);return n.options.address||(n.options.address=t),n}const Je="No deposit ID provided. Please provide a deposit ID as an argument.";var ne=(e=>(e[e.UNREPORTED=0]="UNREPORTED",e[e.REPORTED=1]="REPORTED",e[e.WITHDRAWN=2]="WITHDRAWN",e))(ne||{});async function Xe({rawPayload:e,env:t,...n}){if(!e)throw new Error(Je);const a=new D(n),r=await C(a,t).methods.Bascule().call();if(r===y)return 1;const o=ze(a,r);try{const p=a.getReadWeb3().utils.keccak256(Buffer.from(e.slice(8),"hex")),u=await o.methods.depositHistory(p).call();return Number(u)}catch(p){const u=S(p);throw new Error(u)}}const Ye=[i.ethereum,i.base,i.binanceSmartChain],ae=e=>Ye.includes(e)?l.prod:l.stage;function se(e,t){if(!W(e))throw new Error(`This chain ${e} is not supported`);const n=t?{[e]:t}:N;if(!n[e])throw new Error(`RPC URL for chainId ${e} not found`);return n}async function Qe({chainId:e,rpcUrl:t}){const n=se(e,t),a=new B({chainId:e,rpcUrlConfig:n}),s=ae(e),o=await C(a,s).methods.getMintFee().call();return new I(F(o.toString(10)))}async function et({env:e,rpcUrl:t,chainId:n}){const a={[n]:t},s=new B({chainId:n,rpcUrlConfig:a});return(await C(s,e).methods.totalSupply().call()).toString()}async function ie({owner:e,rpcUrl:t,chainId:n}){const a=se(n,t),s=new B({chainId:n,rpcUrlConfig:a}),r=ae(n),o=C(s,r);try{return(await o.methods.nonces(e).call()).toString()}catch(p){const u=S(p);throw new Error(u)}}async function tt(e){const t=new D(e),n=`destination chain id is ${e.chainId}`;return t.signMessage(n)}const nt=24*60*60;function at({chainId:e,verifyingContract:t,fee:n,expiry:a}){return{domain:{name:"Lombard Staked Bitcoin",version:"1",chainId:e,verifyingContract:t},message:{chainId:e,fee:n,expiry:a},primaryType:"feeApproval",types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],feeApproval:[{name:"chainId",type:"uint256"},{name:"fee",type:"uint256"},{name:"expiry",type:"uint256"}]}}}const st="Failed to obtain a valid signature. The response is undefined or invalid.",it=()=>Math.floor(Date.now()/1e3+nt);async function rt({address:e,provider:t,fee:n,chainId:a,env:s,expiry:r=it()}){var g,m;const o=new D({provider:t,account:e,chainId:a}),u=C(o,s).options.address,T=JSON.stringify(at({chainId:a,verifyingContract:u,fee:n,expiry:r})),c=await((m=(g=o.web3)==null?void 0:g.currentProvider)==null?void 0:m.request({method:"eth_signTypedData_v4",params:[e,T]}));if(typeof c=="string")return{signature:c,typedData:T};if(!(c!=null&&c.result))throw new Error(st);return{signature:c.result,typedData:T}}const V={[i.holesky]:[{key:"veda",name:"Veda / Lombard DeFi Vault",address:"0x4A3cD83CEbb91E0Cd31EdA2Ee0F4AebfcCFCbBb6"}],[i.binanceSmartChain]:[{key:"veda",name:"Veda / Lombard DeFi Vault",address:"0xC8bbF6153D7Ba105f1399D992ebd32B0541996ef"}],[i.binanceSmartChainTestnet]:[{key:"veda",name:"Veda / Lombard DeFi Vault",address:"0x72143309A662bDB4aad5cA65Ab59eD8977D047C5"}]},ot=Object.keys(V).map(Number),re=e=>{const t=V[e];if(!(t!=null&&t.length))throw new Error(`No vaults configured for chain ID ${e}`);return t},oe=(e,t)=>{const a=re(e).find(s=>s.key===t);if(!a)throw new Error(`No vault found with key ${t} for chain ID ${e}`);return a.address};async function pe({chainId:e,expiry:t,owner:n,spender:a,value:s,rpcUrl:r,verifyingContract:o}){const p=await ie({owner:n,chainId:e,rpcUrl:r});return{domain:{name:"Lombard Staked Bitcoin",version:"1",chainId:e,verifyingContract:o},types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},primaryType:"Permit",message:{owner:n,spender:a,value:s,nonce:p,deadline:t.toString()}}}const pt=(e,t=l.prod)=>{const a=G(t)[e];if(!a)throw new Error(`No LBTC contract address configured for chain ID ${e}`);return a},ut="Failed to obtain a valid signature. The response is undefined or invalid.";async function yt({address:e,provider:t,chainId:n,value:a,expiry:s,rpcUrl:r,vaultKey:o,env:p}){var M,E;const u=new D({provider:t,account:e,chainId:n}),T=pt(n,p),c=oe(n,o),g=await pe({chainId:n,expiry:s,owner:e,spender:c,value:a,rpcUrl:r,verifyingContract:T}),m=JSON.stringify(g),b=await((E=(M=u.web3)==null?void 0:M.currentProvider)==null?void 0:E.request({method:"eth_signTypedData_v4",params:[e,m]}));if(typeof b=="string")return{signature:b,typedData:m};if(!(b!=null&&b.result))throw new Error(ut);return{signature:b.result,typedData:m}}x.initEccLib(ce);function dt(e,t=l.prod){var r;const n=lt(e),s=(r=x.payments[n]({address:e,network:t===l.prod?x.networks.bitcoin:x.networks.testnet}).output)==null?void 0:r.toString("hex");if(!s)throw new Error("Output script is not found.");return`0x${s}`}function lt(e){const t=x.address.fromBech32(e);if(t.version===1&&t.data.length===32)return"p2tr";if(t.version===0&&t.data.length===20)return"p2wpkh";if(ct(e))return"p2wsh";throw new Error("Address type is not supported.")}function ct(e){return(e.startsWith("bc1")||e.startsWith("tb1"))&&e.length===62}function mt({btcAddress:e,amount:t,env:n,...a}){const s=new D(a),r=C(s,n),o=dt(e,n),p=U(t),u=r.methods.redeem(o,p);return s.sendTransactionAsync(s.account,r.options.address,{data:u.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:L(s.chainId)})}exports.BasculeDepositStatus=ne;exports.ENotarizationStatus=ee;exports.ESessionState=te;exports.OChainId=i;exports.OEnv=l;exports.SANCTIONED_ADDRESS=X;exports.SATOSHI_SCALE=O;exports.STAKE_AND_BAKE_VAULTS=V;exports.SUPPORTED_STAKE_AND_BAKE_CHAINS=ot;exports.approveLBTC=Ke;exports.claimLBTC=qe;exports.fromSatoshi=F;exports.generateDepositBtcAddress=Ae;exports.getApiConfig=A;exports.getBasculeDepositStatus=Xe;exports.getBaseNetworkByEnv=J;exports.getBscNetworkByEnv=z;exports.getChainIdByName=Q;exports.getChainNameById=P;exports.getDepositBtcAddress=Ce;exports.getDepositBtcAddresses=Y;exports.getDepositsByAddress=_e;exports.getEthNetworkByEnv=q;exports.getLBTCExchangeRate=Me;exports.getLBTCMintingFee=Qe;exports.getLBTCTotalSupply=et;exports.getLbtcAddressConfig=G;exports.getNetworkFeeSignature=Re;exports.getPermitNonce=ie;exports.getStakeAndBakeSpenderContract=oe;exports.getStakeAndBakeTypedData=pe;exports.getStakeAndBakeVaults=re;exports.getUserStakeAndBakeSignature=Ne;exports.isValidChain=W;exports.signLbtcDestionationAddr=tt;exports.signNetworkFee=rt;exports.signStakeAndBake=yt;exports.storeNetworkFeeSignature=Pe;exports.storeStakeAndBakeSignature=Oe;exports.toSatoshi=U;exports.unstakeLBTC=mt;
|
|
1
|
+
"use strict";var ue=Object.defineProperty;var ye=(e,t,n)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _=(e,t,n)=>(ye(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("axios"),I=require("bignumber.js"),f=require("web3"),de=require("@bitcoin-js/tiny-secp256k1-asmjs"),M=require("bitcoinjs-lib");function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const ce=le(de),l={prod:"prod",testnet:"testnet",stage:"stage"},i={ethereum:1,holesky:17e3,binanceSmartChain:56,binanceSmartChainTestnet:97,sepolia:11155111,base:8453,baseSepoliaTestnet:84532,berachainBartioTestnet:80084,corn:21e6,swell:1923},z=e=>e===l.prod?i.ethereum:i.holesky,J=e=>e===l.prod?i.binanceSmartChain:i.binanceSmartChainTestnet,X=e=>e===l.prod?i.base:i.baseSepoliaTestnet,k=l.prod,y="0x0000000000000000000000000000000000000000",me={baseApiUrl:"https://staging.prod.lombard.finance"},be={baseApiUrl:"https://gastald-testnet.prod.lombard.finance"},fe={baseApiUrl:"https://mainnet.prod.lombard.finance"},A=(e=k)=>{switch(e){case l.prod:return fe;case l.testnet:return be;default:return me}};function S(e){return typeof e=="string"?e:(n=>{var a;return((a=n==null?void 0:n.data)==null?void 0:a.message)&&typeof n.data.message=="string"})(e)?e.data.message:e instanceof Error?Te(e):ge(e)}function Te(e){return e.response?e.response.data.message:e.message}function ge(e){return e!=null&&e.message?e.message:"Unknown error"}const w={eth:"DESTINATION_BLOCKCHAIN_ETHEREUM",ethOld:"BLOCKCHAIN_ETHEREUM",base:"DESTINATION_BLOCKCHAIN_BASE",baseOld:"BLOCKCHAIN_BASE",bsc:"DESTINATION_BLOCKCHAIN_BSC",bscOld:"BLOCKCHAIN_BSC"};function O(e){switch(e){case i.ethereum:case i.holesky:case i.sepolia:return w.eth;case i.base:case i.baseSepoliaTestnet:return w.base;case i.binanceSmartChain:case i.binanceSmartChainTestnet:return w.bsc;default:throw new Error(`Unknown chain ID: ${e}`)}}const Y="sanctioned_address",he="api/v1/address/generate",we="destination address is under sanctions";async function Ae({address:e,chainId:t,signature:n,eip712Data:a,env:s,referrerCode:r,partnerId:o,captchaToken:p,signatureData:u}){const{baseApiUrl:T}=A(s),c=O(t),g={to_address:e,to_address_signature:n,to_chain:c,partner_id:o,nonce:0,captcha:p,referrer_code:r,eip_712_data:a,sb_signature_data:u};try{const{data:m}=await v.post(he,g,{baseURL:T});return m.address}catch(m){const b=S(m);if(Se(b))return Y;throw new Error(b)}}function Se(e){return!!e.includes(we)}const ve="api/v1/address";async function Ce({address:e,chainId:t,env:n,partnerId:a}){const s=await Q({address:e,chainId:t,env:n,partnerId:a}),r=Ee(s);if(!r)throw new Error("No address");return r.btc_address}function Ee(e){if(!e.length)return;const t=e.reduce((n,a)=>n.created_at<a.created_at?a:n,e[0]);return t.deprecated?void 0:t}async function Q({address:e,chainId:t,env:n,partnerId:a}){const{baseApiUrl:s}=A(n),r=O(t),o={to_address:e,to_blockchain:r,limit:1,offset:0,asc:!1,referralId:a},{data:p}=await v.get(ve,{baseURL:s,params:o});return(p==null?void 0:p.addresses)||[]}const De=8,B=10**De;function F(e){return+e/B}function U(e){return Math.floor(+e*B)}function ee(e,t=k){switch(e){case w.eth:case w.ethOld:return z(t);case w.base:case w.baseOld:return X(t);case w.bsc:case w.bscOld:return J(t);default:return i.ethereum}}var te=(e=>(e.NOTARIZATION_STATUS_UNSPECIFIED="NOTARIZATION_STATUS_UNSPECIFIED",e.NOTARIZATION_STATUS_PENDING="NOTARIZATION_STATUS_PENDING",e.NOTARIZATION_STATUS_SUBMITTED="NOTARIZATION_STATUS_SUBMITTED",e.NOTARIZATION_STATUS_SESSION_APPROVED="NOTARIZATION_STATUS_SESSION_APPROVED",e.NOTARIZATION_STATUS_FAILED="NOTARIZATION_STATUS_FAILED",e))(te||{}),ne=(e=>(e.SESSION_STATE_UNSPECIFIED="SESSION_STATE_UNSPECIFIED",e.SESSION_STATE_PENDING="SESSION_STATE_PENDING",e.SESSION_STATE_COMPLETED="SESSION_STATE_COMPLETED",e.SESSION_STATE_EXPIRED="SESSION_STATE_EXPIRED",e))(ne||{});async function _e({address:e,env:t}){const{baseApiUrl:n}=A(t),{data:a}=await v.get(`api/v1/address/outputs-v2/${e}`,{baseURL:n});return((a==null?void 0:a.outputs)??[]).map(Ie(t))}function Ie(e){return t=>({txid:t.txid,index:t.index??0,blockHeight:t.block_height?Number(t.block_height):void 0,blockTime:t.block_time?Number(t.block_time):void 0,value:new I(F(t.value)),address:t.address,chainId:ee(t.to_chain,e),claimedTxId:t.claim_tx,isClaimed:!!t.claim_tx,rawPayload:t.raw_payload,signature:t.proof,isRestricted:!!t.sanctioned,notarizationWaitDur:t.notarization_wait_dur?Number(t.notarization_wait_dur):void 0,payload:t.payload_hash,sessionId:t.session_id,notarizationStatus:t.notarization_status,sessionState:t.session_state})}const Me=2e-4;async function xe({env:e,chainId:t=i.ethereum,amount:n=1}){const{baseApiUrl:a}=A(e),s=O(t),{data:r}=await v.get(`api/v1/exchange/rate/${s}`,{baseURL:a,params:{amount:n}}),o=new I(Me).multipliedBy(B).toFixed();return{exchangeRate:+r.amount_out,minAmount:+o}}async function Re({address:e,chainId:t,env:n}){const{baseApiUrl:a}=A(n);try{const{data:s}=await v.get(`${a}/api/v1/claimer/get-user-signature`,{params:{user_destination_address:e,chain_id:t}});return{expirationDate:s==null?void 0:s.expiration_date,hasSignature:s==null?void 0:s.has_signature,isDelayed:s==null?void 0:s.is_delayed}}catch(s){const r=S(s);throw new Error(r)}}async function Ne({userDestinationAddress:e,chainId:t,env:n}){const{baseApiUrl:a}=A(n);try{const{data:s}=await v.get(`${a}/api/v1/claimer/get-user-stake-and-bake-signature`,{params:{userDestinationAddress:e,chainId:t.toString()}});return{userDestinationAddress:s.user_destination_address,signature:s.signature,expirationDate:s.expiration_date,depositAmount:s.deposit_amount,chainId:s.chain_id}}catch(s){const r=S(s);throw new Error(`Failed to get user stake and bake signature: ${r}`)}}async function Pe({signature:e,typedData:t,address:n,env:a}){const{baseApiUrl:s}=A(a);try{const{data:r}=await v.post(`${s}/api/v1/claimer/save-user-signature`,null,{params:{typed_data:t,signature:e,user_destination_address:n}});return r.status}catch(r){const o=S(r);throw new Error(o)}}async function Oe({signature:e,typedData:t,env:n}){const{baseApiUrl:a}=A(n);try{const{data:s}=await v.post(`${a}/api/v1/claimer/save-stake-and-bake-signature`,null,{params:{typed_data:t,signature:e}});return s.status}catch(s){const r=S(s);throw new Error(r)}}const P={[i.ethereum]:"https://rpc.ankr.com/eth",[i.holesky]:"https://rpc.ankr.com/eth_holesky",[i.sepolia]:"https://rpc.ankr.com/eth_sepolia",[i.base]:"https://rpc.ankr.com/base",[i.baseSepoliaTestnet]:"https://rpc.ankr.com/base_sepolia",[i.binanceSmartChain]:"https://bsc-dataseed.bnbchain.org",[i.binanceSmartChainTestnet]:"https://bsc-testnet-dataseed.bnbchain.org"};async function Be(e){const n=await(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"eth_maxPriorityFeePerGas",params:[]})})).json(),a=f.utils.hexToNumber(n==null?void 0:n.result);return new I(Number(a))}const ke=2,Fe=25e3;class x{constructor({chainId:t,rpcUrlConfig:n}){_(this,"chainId");_(this,"rpcConfig");this.chainId=t,this.rpcConfig={...P,...n}}getReadWeb3(){const t=this.getRpcUrl(),n=new f.Web3,a=new f.Web3.providers.HttpProvider(t);return n.setProvider(a),n}getRpcUrl(){var a;const{chainId:t}=this,n=(a=this.rpcConfig)==null?void 0:a[t];if(!n)throw console.error(`You might need to add the rpcConfig for the ${t} chain ID when creating the provider.`),new Error(`RPC URL for chainId ${t} not found`);return n}async getMaxFees(){const t=this.getReadWeb3(),n=this.getRpcUrl(),[a,s]=await Promise.all([t.eth.getBlock("latest"),Be(n)]);return!(a!=null&&a.baseFeePerGas)&&typeof(a==null?void 0:a.baseFeePerGas)!="bigint"?{}:{maxFeePerGas:+new I(a.baseFeePerGas.toString(10)).multipliedBy(ke).plus(s),maxPriorityFeePerGas:+s}}async getSafeGasPriceWei(){const t=await this.getReadWeb3().eth.getGasPrice();return new I(t.toString(10)).plus(Fe)}createContract(t,n){const a=this.getReadWeb3();return new a.eth.Contract(t,n)}}class D extends x{constructor({provider:n,account:a,chainId:s,rpcUrlConfig:r}){super({chainId:s,rpcUrlConfig:r});_(this,"web3");_(this,"account");_(this,"rpcConfig",P);this.web3=new f(n),this.account=a,this.chainId=s,this.rpcConfig={...P,...r}}async signMessage(n){const{account:a}=this,s=`0x${Buffer.from(n,"utf8").toString("hex")}`;return this.web3.currentProvider.request({method:"personal_sign",params:[s,a]})}async sendTransactionAsync(n,a,s){const{chainId:r,web3:o}=this,p=this.getReadWeb3(),{data:u,estimate:T=!1,estimateFee:c=!1,extendedGasLimit:g,gasLimit:m="0",value:b="0",gasLimitMultiplier:R=1}=s;let{nonce:E}=s;E||(E=await p.eth.getTransactionCount(n)),console.log(`Nonce: ${E}`);const d={from:n,to:a,value:f.utils.numberToHex(b),data:u,nonce:E,chainId:f.utils.numberToHex(r)};if(T)try{const h=await p.eth.estimateGas(d),N=Math.round(Number(h)*R);g?d.gas=f.utils.numberToHex(N+g):d.gas=f.utils.numberToHex(N)}catch(h){throw new Error(h.message??"Failed to estimate gas limit for transaction.")}else d.gas=f.utils.numberToHex(m);const{maxFeePerGas:$,maxPriorityFeePerGas:K}=c?await this.getMaxFees().catch(()=>s):s;if(K!==void 0&&(d.maxPriorityFeePerGas=f.utils.numberToHex(K)),$!==void 0&&(d.maxFeePerGas=f.utils.numberToHex($)),!d.maxFeePerGas&&!d.maxPriorityFeePerGas){const h=await this.getSafeGasPriceWei();d.gasPrice=h.toString(10)}if(!d.maxFeePerGas&&!d.maxPriorityFeePerGas){const h=await this.getSafeGasPriceWei();d.gasPrice=h.toString(10)}return console.log("Sending transaction via Web3: ",d),new Promise((h,N)=>{const Z=o.eth.sendTransaction(d);Z.once("transactionHash",async j=>{console.log(`Just signed transaction has is: ${j}`),h({receiptPromise:Z,transactionHash:j})}).catch(N)})}createContract(n,a){return new this.web3.eth.Contract(n,a)}}function L(e){switch(e){case i.ethereum:return 1.3;case i.holesky:case i.sepolia:return 1.5;default:return 1.3}}function W(e){return Object.values(i).includes(e)}const Ue={[i.holesky]:"0xED7bfd5C1790576105Af4649817f6d35A75CD818",[i.ethereum]:y,[i.binanceSmartChainTestnet]:"0x731eFa688F3679688cf60A3993b8658138953ED6",[i.binanceSmartChain]:y,[i.sepolia]:"0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",[i.base]:y,[i.baseSepoliaTestnet]:"0x731eFa688F3679688cf60A3993b8658138953ED6",[i.berachainBartioTestnet]:"0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",[i.corn]:y,[i.swell]:y},Le={[i.holesky]:"0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",[i.ethereum]:y,[i.binanceSmartChainTestnet]:"0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",[i.binanceSmartChain]:y,[i.sepolia]:"0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",[i.base]:y,[i.baseSepoliaTestnet]:y,[i.berachainBartioTestnet]:"0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",[i.corn]:y,[i.swell]:y},We={[i.ethereum]:"0x8236a87084f8b84306f72007f36f2618a5634494",[i.holesky]:y,[i.sepolia]:y,[i.binanceSmartChainTestnet]:y,[i.binanceSmartChain]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[i.base]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[i.baseSepoliaTestnet]:y,[i.berachainBartioTestnet]:y,[i.corn]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[i.swell]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1"};function G(e=k){switch(e){case l.prod:return We;case l.testnet:return Le;default:return Ue}}const Ge=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],Ve=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{internalType:"uint256",name:"dustLimit",type:"uint256"}],name:"AmountBelowDustLimit",type:"error"},{inputs:[{internalType:"uint256",name:"fee",type:"uint256"}],name:"AmountLessThanCommission",type:"error"},{inputs:[],name:"ECDSAInvalidSignature",type:"error"},{inputs:[{internalType:"uint256",name:"length",type:"uint256"}],name:"ECDSAInvalidSignatureLength",type:"error"},{inputs:[{internalType:"bytes32",name:"s",type:"bytes32"}],name:"ECDSAInvalidSignatureS",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"allowance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientAllowance",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"balance",type:"uint256"},{internalType:"uint256",name:"needed",type:"uint256"}],name:"ERC20InsufficientBalance",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC20InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC20InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC20InvalidSender",type:"error"},{inputs:[{internalType:"address",name:"spender",type:"address"}],name:"ERC20InvalidSpender",type:"error"},{inputs:[{internalType:"uint256",name:"deadline",type:"uint256"}],name:"ERC2612ExpiredSignature",type:"error"},{inputs:[{internalType:"address",name:"signer",type:"address"},{internalType:"address",name:"owner",type:"address"}],name:"ERC2612InvalidSigner",type:"error"},{inputs:[],name:"EnforcedPause",type:"error"},{inputs:[],name:"ExpectedPause",type:"error"},{inputs:[],name:"FeeGreaterThanAmount",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"uint256",name:"currentNonce",type:"uint256"}],name:"InvalidAccountNonce",type:"error"},{inputs:[],name:"InvalidDustFeeRate",type:"error"},{inputs:[],name:"InvalidInitialization",type:"error"},{inputs:[],name:"InvalidInputLength",type:"error"},{inputs:[],name:"InvalidUserSignature",type:"error"},{inputs:[],name:"KnownDestination",type:"error"},{inputs:[],name:"NotInitializing",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[],name:"PayloadAlreadyUsed",type:"error"},{inputs:[],name:"ReentrancyGuardReentrantCall",type:"error"},{inputs:[],name:"ScriptPubkeyUnsupported",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"UnauthorizedAccount",type:"error"},{inputs:[{internalType:"bytes4",name:"action",type:"bytes4"}],name:"UnexpectedAction",type:"error"},{inputs:[],name:"UnknownDestination",type:"error"},{inputs:[{internalType:"uint256",name:"fromChainId",type:"uint256"},{internalType:"address",name:"fromContract",type:"address"}],name:"UnknownOriginContract",type:"error"},{inputs:[{internalType:"uint256",name:"expiry",type:"uint256"}],name:"UserSignatureExpired",type:"error"},{inputs:[],name:"WithdrawalsDisabled",type:"error"},{inputs:[],name:"WrongChainId",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{inputs:[],name:"ZeroAmount",type:"error"},{inputs:[],name:"ZeroChainId",type:"error"},{inputs:[],name:"ZeroContractHash",type:"error"},{inputs:[],name:"ZeroFee",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"prevVal",type:"address"},{indexed:!0,internalType:"address",name:"newVal",type:"address"}],name:"BasculeChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"prevVal",type:"address"},{indexed:!0,internalType:"address",name:"newVal",type:"address"}],name:"BridgeChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint64",name:"prevValue",type:"uint64"},{indexed:!0,internalType:"uint64",name:"newValue",type:"uint64"}],name:"BurnCommissionChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"claimer",type:"address"},{indexed:!1,internalType:"bool",name:"isClaimer",type:"bool"}],name:"ClaimerUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"prevVal",type:"address"},{indexed:!0,internalType:"address",name:"newVal",type:"address"}],name:"ConsortiumChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oldRate",type:"uint256"},{indexed:!0,internalType:"uint256",name:"newRate",type:"uint256"}],name:"DustFeeRateChanged",type:"event"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"oldFee",type:"uint256"},{indexed:!0,internalType:"uint256",name:"newFee",type:"uint256"}],name:"FeeChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"fee",type:"uint256"},{indexed:!1,internalType:"bytes",name:"userSignature",type:"bytes"}],name:"FeeCharged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint64",name:"version",type:"uint64"}],name:"Initialized",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"recipient",type:"address"},{indexed:!0,internalType:"bytes32",name:"payloadHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"payload",type:"bytes"}],name:"MintProofConsumed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"minter",type:"address"},{indexed:!1,internalType:"bool",name:"isMinter",type:"bool"}],name:"MinterUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"string",name:"name",type:"string"},{indexed:!1,internalType:"string",name:"symbol",type:"string"}],name:"NameAndSymbolChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferStarted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousPauser",type:"address"},{indexed:!0,internalType:"address",name:"newPauser",type:"address"}],name:"PauserRoleTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"prevValue",type:"address"},{indexed:!0,internalType:"address",name:"newValue",type:"address"}],name:"TreasuryAddressChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"fromAddress",type:"address"},{indexed:!1,internalType:"bytes",name:"scriptPubKey",type:"bytes"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"UnstakeRequest",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bool",name:"",type:"bool"}],name:"WithdrawalsEnabled",type:"event"},{inputs:[],name:"Bascule",outputs:[{internalType:"contract IBascule",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"acceptOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newClaimer",type:"address"}],name:"addClaimer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newMinter",type:"address"}],name:"addMinter",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address[]",name:"to",type:"address[]"},{internalType:"uint256[]",name:"amount",type:"uint256[]"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes[]",name:"payload",type:"bytes[]"},{internalType:"bytes[]",name:"proof",type:"bytes[]"}],name:"batchMint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes[]",name:"mintPayload",type:"bytes[]"},{internalType:"bytes[]",name:"proof",type:"bytes[]"},{internalType:"bytes[]",name:"feePayload",type:"bytes[]"},{internalType:"bytes[]",name:"userSignature",type:"bytes[]"}],name:"batchMintWithFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"burn",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"scriptPubkey",type:"bytes"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"calcUnstakeRequestAmount",outputs:[{internalType:"uint256",name:"amountAfterFee",type:"uint256"},{internalType:"bool",name:"isAboveDust",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newVal",type:"address"}],name:"changeBascule",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newBridge",type:"address"}],name:"changeBridge",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint64",name:"newValue",type:"uint64"}],name:"changeBurnCommission",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newVal",type:"address"}],name:"changeConsortium",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newRate",type:"uint256"}],name:"changeDustFeeRate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"string",name:"name_",type:"string"},{internalType:"string",name:"symbol_",type:"string"}],name:"changeNameAndSymbol",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newValue",type:"address"}],name:"changeTreasuryAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"consortium",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getBurnCommission",outputs:[{internalType:"uint64",name:"",type:"uint64"}],stateMutability:"view",type:"function"},{inputs:[],name:"getDustFeeRate",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getMintFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"getTreasury",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"consortium_",type:"address"},{internalType:"uint64",name:"burnCommission_",type:"uint64"},{internalType:"address",name:"owner_",type:"address"}],name:"initialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"claimer",type:"address"}],name:"isClaimer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"minter",type:"address"}],name:"isMinter",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"payload",type:"bytes"},{internalType:"bytes",name:"proof",type:"bytes"}],name:"mint",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"mintPayload",type:"bytes"},{internalType:"bytes",name:"proof",type:"bytes"},{internalType:"bytes",name:"feePayload",type:"bytes"},{internalType:"bytes",name:"userSignature",type:"bytes"}],name:"mintWithFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"nonces",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"pauser",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pendingOwner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"scriptPubkey",type:"bytes"},{internalType:"uint256",name:"amount",type:"uint256"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"reinitialize",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oldClaimer",type:"address"}],name:"removeClaimer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"oldMinter",type:"address"}],name:"removeMinter",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"fee",type:"uint256"}],name:"setMintFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"toggleWithdrawals",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newPauser",type:"address"}],name:"transferPauserRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"fromChain",type:"uint256"},{internalType:"address",name:"fromContract",type:"address"},{internalType:"uint256",name:"toChain",type:"uint256"},{internalType:"address",name:"toContract",type:"address"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint64",name:"amount",type:"uint64"},{internalType:"bytes32",name:"uniqueActionData",type:"bytes32"}],internalType:"struct Actions.DepositBridgeAction",name:"action",type:"tuple"},{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"bytes",name:"",type:"bytes"}],name:"withdraw",outputs:[],stateMutability:"nonpayable",type:"function"}],He=[{inputs:[{internalType:"address",name:"aDefaultAdmin",type:"address"},{internalType:"address",name:"aPauser",type:"address"},{internalType:"address",name:"aDepositReporter",type:"address"},{internalType:"address",name:"aWithdrawalValidator",type:"address"},{internalType:"uint256",name:"aMaxDeposits",type:"uint256"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"AccessControlBadConfirmation",type:"error"},{inputs:[{internalType:"uint48",name:"schedule",type:"uint48"}],name:"AccessControlEnforcedDefaultAdminDelay",type:"error"},{inputs:[],name:"AccessControlEnforcedDefaultAdminRules",type:"error"},{inputs:[{internalType:"address",name:"defaultAdmin",type:"address"}],name:"AccessControlInvalidDefaultAdmin",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"},{internalType:"bytes32",name:"neededRole",type:"bytes32"}],name:"AccessControlUnauthorizedAccount",type:"error"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"}],name:"AlreadyReported",type:"error"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"},{internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"AlreadyWithdrawn",type:"error"},{inputs:[],name:"BadDepositReport",type:"error"},{inputs:[],name:"EnforcedPause",type:"error"},{inputs:[],name:"ExpectedPause",type:"error"},{inputs:[{internalType:"uint8",name:"bits",type:"uint8"},{internalType:"uint256",name:"value",type:"uint256"}],name:"SafeCastOverflowedUintDowncast",type:"error"},{inputs:[],name:"SameValidationThreshold",type:"error"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"},{internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"WithdrawalFailedValidation",type:"error"},{anonymous:!1,inputs:[],name:"DefaultAdminDelayChangeCanceled",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint48",name:"newDelay",type:"uint48"},{indexed:!1,internalType:"uint48",name:"effectSchedule",type:"uint48"}],name:"DefaultAdminDelayChangeScheduled",type:"event"},{anonymous:!1,inputs:[],name:"DefaultAdminTransferCanceled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"newAdmin",type:"address"},{indexed:!1,internalType:"uint48",name:"acceptSchedule",type:"uint48"}],name:"DefaultAdminTransferScheduled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"reportId",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"numDeposits",type:"uint256"}],name:"DepositsReported",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"numDeposits",type:"uint256"}],name:"MaxDepositsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"previousAdminRole",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"newAdminRole",type:"bytes32"}],name:"RoleAdminChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleGranted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"role",type:"bytes32"},{indexed:!0,internalType:"address",name:"account",type:"address"},{indexed:!0,internalType:"address",name:"sender",type:"address"}],name:"RoleRevoked",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"uint256",name:"oldThreshold",type:"uint256"},{indexed:!1,internalType:"uint256",name:"newThreshold",type:"uint256"}],name:"UpdateValidateThreshold",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bytes32",name:"depositID",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"WithdrawalNotValidated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"bytes32",name:"depositID",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"WithdrawalValidated",type:"event"},{inputs:[],name:"DEFAULT_ADMIN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"DEPOSIT_REPORTER_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"PAUSER_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"VALIDATION_GUARDIAN_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"WITHDRAWAL_VALIDATOR_ROLE",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"acceptDefaultAdminTransfer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newAdmin",type:"address"}],name:"beginDefaultAdminTransfer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"cancelDefaultAdminTransfer",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint48",name:"newDelay",type:"uint48"}],name:"changeDefaultAdminDelay",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"defaultAdmin",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"defaultAdminDelay",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[],name:"defaultAdminDelayIncreaseWait",outputs:[{internalType:"uint48",name:"",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"}],name:"depositHistory",outputs:[{internalType:"enum Bascule.DepositState",name:"status",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"}],name:"getRoleAdmin",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"grantRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"hasRole",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxDeposits",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"pendingDefaultAdmin",outputs:[{internalType:"address",name:"newAdmin",type:"address"},{internalType:"uint48",name:"schedule",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[],name:"pendingDefaultAdminDelay",outputs:[{internalType:"uint48",name:"newDelay",type:"uint48"},{internalType:"uint48",name:"schedule",type:"uint48"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"renounceRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"reportId",type:"bytes32"},{internalType:"bytes32[]",name:"depositIDs",type:"bytes32[]"}],name:"reportDeposits",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"role",type:"bytes32"},{internalType:"address",name:"account",type:"address"}],name:"revokeRole",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"rollbackDefaultAdminDelay",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"aMaxDeposits",type:"uint256"}],name:"setMaxDeposits",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"newThreshold",type:"uint256"}],name:"updateValidateThreshold",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"validateThreshold",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"depositID",type:"bytes32"},{internalType:"uint256",name:"withdrawalAmount",type:"uint256"}],name:"validateWithdrawal",outputs:[],stateMutability:"nonpayable",type:"function"}],$e=[{inputs:[],name:"getStakeAndBakeFee",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"}];function Ke(e){switch(e){case"LBTC":return Ve;default:return Ge}}function C(e,t){const n=G(t),{chainId:a}=e;if(!W(a))throw new Error(`This chain ${a} is not supported`);const s=n[a];if(!s)throw new Error(`Token address for chain ${a} is not defined`);const r=Ke("LBTC"),o=e.createContract(r,s);return o.options.address||(o.options.address=s),o}function Ze({spender:e,amount:t,env:n,...a}){const s=new D(a),r=C(s,n),o=U(t),p=r.methods.approve(e,o);return s.sendTransactionAsync(s.account,r.options.address,{data:p.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:L(s.chainId)})}const je="insufficient funds",qe="Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.",q=e=>e.startsWith("0x")?e:"0x"+e;async function ze({data:e,proofSignature:t,env:n,...a}){const s=new D(a),r=C(s,n),o=r.methods.mint(q(e),q(t));try{return await s.sendTransactionAsync(s.account,r.options.address,{data:o.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:L(s.chainId)})}catch(p){console.log("error",p);const u=S(p);throw u.includes(je)?new Error(qe):new Error(u)}}function Je(e,t){if(!t)throw new Error("The address for bascule module is not defined");const n=e.createContract(He,t);return n.options.address||(n.options.address=t),n}const Xe="No deposit ID provided. Please provide a deposit ID as an argument.";var ae=(e=>(e[e.UNREPORTED=0]="UNREPORTED",e[e.REPORTED=1]="REPORTED",e[e.WITHDRAWN=2]="WITHDRAWN",e))(ae||{});async function Ye({rawPayload:e,env:t,...n}){if(!e)throw new Error(Xe);const a=new D(n),r=await C(a,t).methods.Bascule().call();if(r===y)return 1;const o=Je(a,r);try{const p=a.getReadWeb3().utils.keccak256(Buffer.from(e.slice(8),"hex")),u=await o.methods.depositHistory(p).call();return Number(u)}catch(p){const u=S(p);throw new Error(u)}}const Qe=[i.ethereum,i.base,i.binanceSmartChain],se=e=>Qe.includes(e)?l.prod:l.stage;function V(e,t){if(!W(e))throw new Error(`This chain ${e} is not supported`);const n=t?{[e]:t}:P;if(!n[e])throw new Error(`RPC URL for chainId ${e} not found`);return n}async function et({chainId:e,rpcUrl:t}){const n=V(e,t),a=new x({chainId:e,rpcUrlConfig:n}),s=se(e),o=await C(a,s).methods.getMintFee().call();return new I(F(o.toString(10)))}async function tt({env:e,rpcUrl:t,chainId:n}){const a={[n]:t},s=new x({chainId:n,rpcUrlConfig:a});return(await C(s,e).methods.totalSupply().call()).toString()}async function ie({owner:e,rpcUrl:t,chainId:n}){const a=V(n,t),s=new x({chainId:n,rpcUrlConfig:a}),r=se(n),o=C(s,r);try{return(await o.methods.nonces(e).call()).toString()}catch(p){const u=S(p);throw new Error(u)}}async function nt(e){const t=new D(e),n=`destination chain id is ${e.chainId}`;return t.signMessage(n)}const at=24*60*60;function st({chainId:e,verifyingContract:t,fee:n,expiry:a}){return{domain:{name:"Lombard Staked Bitcoin",version:"1",chainId:e,verifyingContract:t},message:{chainId:e,fee:n,expiry:a},primaryType:"feeApproval",types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],feeApproval:[{name:"chainId",type:"uint256"},{name:"fee",type:"uint256"},{name:"expiry",type:"uint256"}]}}}const it="Failed to obtain a valid signature. The response is undefined or invalid.",rt=()=>Math.floor(Date.now()/1e3+at);async function ot({address:e,provider:t,fee:n,chainId:a,env:s,expiry:r=rt()}){var g,m;const o=new D({provider:t,account:e,chainId:a}),u=C(o,s).options.address,T=JSON.stringify(st({chainId:a,verifyingContract:u,fee:n,expiry:r})),c=await((m=(g=o.web3)==null?void 0:g.currentProvider)==null?void 0:m.request({method:"eth_signTypedData_v4",params:[e,T]}));if(typeof c=="string")return{signature:c,typedData:T};if(!(c!=null&&c.result))throw new Error(it);return{signature:c.result,typedData:T}}const H={[i.holesky]:[{key:"veda",name:"Veda / Lombard DeFi Vault",address:"0x4A3cD83CEbb91E0Cd31EdA2Ee0F4AebfcCFCbBb6"}],[i.binanceSmartChain]:[{key:"veda",name:"Veda / Lombard DeFi Vault",address:"0xC8bbF6153D7Ba105f1399D992ebd32B0541996ef"}],[i.binanceSmartChainTestnet]:[{key:"veda",name:"Veda / Lombard DeFi Vault",address:"0x72143309A662bDB4aad5cA65Ab59eD8977D047C5"}]},pt=Object.keys(H).map(Number),re=e=>{const t=H[e];if(!(t!=null&&t.length))throw new Error(`No vaults configured for chain ID ${e}`);return t},oe=(e,t)=>{const a=re(e).find(s=>s.key===t);if(!a)throw new Error(`No vault found with key ${t} for chain ID ${e}`);return a.address};async function pe({chainId:e,expiry:t,owner:n,spender:a,value:s,rpcUrl:r,verifyingContract:o}){const p=await ie({owner:n,chainId:e,rpcUrl:r});return{domain:{name:"Lombard Staked Bitcoin",version:"1",chainId:e,verifyingContract:o},types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"}],Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},primaryType:"Permit",message:{owner:n,spender:a,value:s,nonce:p,deadline:t.toString()}}}const ut=(e,t=l.prod)=>{const a=G(t)[e];if(!a)throw new Error(`No LBTC contract address configured for chain ID ${e}`);return a},yt="Failed to obtain a valid signature. The response is undefined or invalid.";async function dt({address:e,provider:t,chainId:n,value:a,expiry:s,rpcUrl:r,vaultKey:o,env:p}){var R,E;const u=new D({provider:t,account:e,chainId:n}),T=ut(n,p),c=oe(n,o),g=await pe({chainId:n,expiry:s,owner:e,spender:c,value:a,rpcUrl:r,verifyingContract:T}),m=JSON.stringify(g),b=await((E=(R=u.web3)==null?void 0:R.currentProvider)==null?void 0:E.request({method:"eth_signTypedData_v4",params:[e,m]}));if(typeof b=="string")return{signature:b,typedData:m};if(!(b!=null&&b.result))throw new Error(yt);return{signature:b.result,typedData:m}}M.initEccLib(ce);function lt(e,t=l.prod){var r;const n=ct(e),s=(r=M.payments[n]({address:e,network:t===l.prod?M.networks.bitcoin:M.networks.testnet}).output)==null?void 0:r.toString("hex");if(!s)throw new Error("Output script is not found.");return`0x${s}`}function ct(e){const t=M.address.fromBech32(e);if(t.version===1&&t.data.length===32)return"p2tr";if(t.version===0&&t.data.length===20)return"p2wpkh";if(mt(e))return"p2wsh";throw new Error("Address type is not supported.")}function mt(e){return(e.startsWith("bc1")||e.startsWith("tb1"))&&e.length===62}function bt({btcAddress:e,amount:t,env:n,...a}){const s=new D(a),r=C(s,n),o=lt(e,n),p=U(t),u=r.methods.redeem(o,p);return s.sendTransactionAsync(s.account,r.options.address,{data:u.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:L(s.chainId)})}async function ft({chainId:e,rpcUrl:t,vaultAddress:n}){const a=V(e,t),s=new x({chainId:e,rpcUrlConfig:a});try{return(await s.createContract($e,n).methods.getStakeAndBakeFee().call()).toString()}catch(r){const o=S(r);throw new Error(o)}}exports.BasculeDepositStatus=ae;exports.ENotarizationStatus=te;exports.ESessionState=ne;exports.OChainId=i;exports.OEnv=l;exports.SANCTIONED_ADDRESS=Y;exports.SATOSHI_SCALE=B;exports.STAKE_AND_BAKE_VAULTS=H;exports.SUPPORTED_STAKE_AND_BAKE_CHAINS=pt;exports.approveLBTC=Ze;exports.claimLBTC=ze;exports.fromSatoshi=F;exports.generateDepositBtcAddress=Ae;exports.getApiConfig=A;exports.getBasculeDepositStatus=Ye;exports.getBaseNetworkByEnv=X;exports.getBscNetworkByEnv=J;exports.getChainIdByName=ee;exports.getChainNameById=O;exports.getDepositBtcAddress=Ce;exports.getDepositBtcAddresses=Q;exports.getDepositsByAddress=_e;exports.getEthNetworkByEnv=z;exports.getLBTCExchangeRate=xe;exports.getLBTCMintingFee=et;exports.getLBTCTotalSupply=tt;exports.getLbtcAddressConfig=G;exports.getNetworkFeeSignature=Re;exports.getPermitNonce=ie;exports.getStakeAndBakeFee=ft;exports.getStakeAndBakeSpenderContract=oe;exports.getStakeAndBakeTypedData=pe;exports.getStakeAndBakeVaults=re;exports.getUserStakeAndBakeSignature=Ne;exports.isValidChain=W;exports.signLbtcDestionationAddr=nt;exports.signNetworkFee=ot;exports.signStakeAndBake=dt;exports.storeNetworkFeeSignature=Pe;exports.storeStakeAndBakeSignature=Oe;exports.toSatoshi=U;exports.unstakeLBTC=bt;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|