@lombard.finance/sdk 2.0.15 → 2.1.0
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 +105 -6
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +443 -629
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/common/types/types.ts +2 -9
- package/src/provider/Provider.ts +1 -0
- package/src/provider/rpcUrlConfig.ts +3 -3
- package/src/sdk/generateDepositBtcAddress/generateDepositBtcAddress.ts +6 -0
- package/src/sdk/getDepositsByAddress/getDepositsByAddress.ts +2 -0
- package/src/sdk/getNetworkFeeSignature/getNetworkFeeSignature.stories.tsx +1 -1
- package/src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.stories.tsx +1 -1
- package/src/sdk/getUserStakeAndBakeSignature/getUserStakeAndBakeSignature.ts +20 -2
- package/src/sdk/internalTypes.ts +5 -5
- package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.stories.tsx +26 -102
- package/src/sdk/storeStakeAndBakeSignature/storeStakeAndBakeSignature.ts +1 -1
- package/src/sdk/utils/getChainIdByName.ts +5 -0
- package/src/sdk/utils/getChainNameById.ts +1 -1
- package/src/web3Sdk/basculeAddressConfig.ts +70 -0
- package/src/web3Sdk/claimLBTC/claimLBTC.ts +0 -1
- package/src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.stories.tsx +3 -3
- package/src/web3Sdk/getBasculeDepositStatus/getBasculeDepositStatus.ts +12 -15
- package/src/web3Sdk/index.ts +8 -2
- package/src/web3Sdk/lbtcAddressConfig.ts +4 -4
- package/src/web3Sdk/signStakeAndBake/contracts.ts +74 -5
- package/src/web3Sdk/signStakeAndBake/signStakeAndBake.stories.tsx +25 -100
- package/src/web3Sdk/signStakeAndBake/signStakeAndBake.ts +5 -3
- package/src/web3Sdk/lbtcOFTAdapterAddressConfig.ts +0 -47
- package/src/web3Sdk/signStakeAndBake/config.ts +0 -10
package/README.md
CHANGED
|
@@ -44,12 +44,15 @@ const { getDepositBtcAddress } = require('@lombard.finance/sdk');
|
|
|
44
44
|
- [generateDepositBtcAddress](#generateDepositBtcAddress)
|
|
45
45
|
- [getDepositsByAddress](#getDepositsByAddress)
|
|
46
46
|
- [getLBTCExchangeRate](#getLBTCExchangeRate)
|
|
47
|
+
- [storeStakeAndBakeSignature](#storeStakeAndBakeSignature)
|
|
48
|
+
- [getUserStakeAndBakeSignature](#getUserStakeAndBakeSignature)
|
|
47
49
|
- Web3 based
|
|
48
50
|
- [signLbtcDestionationAddr](#signLbtcDestionationAddr)
|
|
49
51
|
- [claimLBTC](#claimLBTC)
|
|
50
52
|
- [unstakeLBTC](#unstakeLBTC)
|
|
51
53
|
- [getBasculeDepositStatus](#getBasculeDepositStatus)
|
|
52
54
|
- [getLBTCTotalSupply](#getLBTCTotalSupply)
|
|
55
|
+
- [signStakeAndBake](#signStakeAndBake)
|
|
53
56
|
|
|
54
57
|
#### getDepositBtcAddress
|
|
55
58
|
|
|
@@ -322,11 +325,107 @@ const totalSupply = await getLBTCTotalSupply({
|
|
|
322
325
|
console.log(totalSupply); // '2000000'
|
|
323
326
|
```
|
|
324
327
|
|
|
325
|
-
|
|
328
|
+
#### signStakeAndBake
|
|
326
329
|
|
|
327
|
-
|
|
330
|
+
`@returns Promise<ISignStakeAndBakeResult>` Sign authorization promise
|
|
328
331
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
332
|
+
Sign Stake And Bake
|
|
333
|
+
|
|
334
|
+
## Parameters
|
|
335
|
+
|
|
336
|
+
| name | type | description |
|
|
337
|
+
|--------------|---------------------|-----------------------------------------------------------------------------|
|
|
338
|
+
| `provider` | `IProvider` | Provider instance to interact with the blockchain |
|
|
339
|
+
| `address` | `string` | The address to sign with (owner) |
|
|
340
|
+
| `chainId` | `TChainId` | Chain ID for the signature |
|
|
341
|
+
| `value` | `string` | The value to approve |
|
|
342
|
+
| `expiry` | `number` | Expiry date as a unix timestamp |
|
|
343
|
+
| `rpcUrl` | `string` (optional) | Optional RPC URL for the network |
|
|
344
|
+
| `vaultKey` | `string` | The key of the vault to authorize |
|
|
345
|
+
|
|
346
|
+
Usage
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
import { signStakeAndBake } from '@lombard.finance/sdk';
|
|
350
|
+
|
|
351
|
+
const { signature, signatureData } = await signStakeAndBake({
|
|
352
|
+
provider: window.ethereum,
|
|
353
|
+
address: '0x...',
|
|
354
|
+
chainId,
|
|
355
|
+
value: toSatoshi(approvalValue.toString()).toString(),
|
|
356
|
+
expiry: permitExpiryTime,
|
|
357
|
+
vaultKey: selectedVault.key
|
|
358
|
+
});
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### storeStakeAndBakeSignature
|
|
362
|
+
|
|
363
|
+
`@returns Promise<IStoreStakeAndBakeSignatureStatus>` Store Stake And Bake Signature Status promise
|
|
364
|
+
|
|
365
|
+
Store stake and bake signature
|
|
366
|
+
|
|
367
|
+
## Parameters
|
|
368
|
+
|
|
369
|
+
| name | type | description |
|
|
370
|
+
|--------------|---------------------|---------------------------------------------|
|
|
371
|
+
| `env` | `TEnv` | Environment (e.g., 'prod', 'dev', etc.) |
|
|
372
|
+
| `signature` | `string` | The generated signature |
|
|
373
|
+
| `typedData` | `string` | JSON typed data used for the signature |
|
|
374
|
+
|
|
375
|
+
Usage
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
import { storeStakeAndBakeSignature } from '@lombard.finance/sdk';
|
|
379
|
+
|
|
380
|
+
const status = await storeStakeAndBakeSignature({ signature, signatureData, env: 'prod' });
|
|
381
|
+
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
#### getUserStakeAndBakeSignature
|
|
385
|
+
|
|
386
|
+
`@returns Promise<IGetUserStakeAndBakeSignatureResponse>` Promise that resolves to the signature response
|
|
387
|
+
|
|
388
|
+
Get user's stake and bake signature from the API
|
|
389
|
+
|
|
390
|
+
## Parameters
|
|
391
|
+
|
|
392
|
+
| name | type | description |
|
|
393
|
+
|-------------------------|----------|--------------------------------------------|
|
|
394
|
+
| `userDestinationAddress`| `string` | The user's destination address |
|
|
395
|
+
| `chainId` | `string` | The chain ID |
|
|
396
|
+
| `env` | `TEnv` | Environment (e.g., 'prod', 'dev', etc.) |
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
Usage
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
import { getUserStakeAndBakeSignature } from '@lombard.finance/sdk';
|
|
403
|
+
|
|
404
|
+
const response = await getUserStakeAndBakeSignature({
|
|
405
|
+
userDestinationAddress: address,
|
|
406
|
+
chainId,
|
|
407
|
+
env: 'prod'
|
|
408
|
+
});
|
|
409
|
+
console.log(response);
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
#### getStakeAndBakeVaults
|
|
413
|
+
|
|
414
|
+
`@returns IStakeAndBakeVault[]` A list of available vaults
|
|
415
|
+
|
|
416
|
+
## Parameters
|
|
417
|
+
|
|
418
|
+
| name | type | description |
|
|
419
|
+
|-------------------------|----------|--------------------------------------------|
|
|
420
|
+
| `chainId` | `string` | The chain ID |
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
Usage
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
import { getStakeAndBakeVaults } from '@lombard.finance/sdk';
|
|
427
|
+
|
|
428
|
+
const vaults = getStakeAndBakeVaults(1);
|
|
429
|
+
|
|
430
|
+
console.log(vaults);
|
|
431
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var ve=Object.defineProperty;var Re=(e,t,n)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var R=(e,t,n)=>(Re(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("axios"),C=require("bignumber.js"),f=require("web3"),h={prod:"prod",testnet:"testnet",stage:"stage"},i={ethereum:1,holesky:17e3,binanceSmartChain:56,binanceSmartChainTestnet:97,sepolia:11155111,base:8453,baseTestnet:84532,berachainBartioTestnet:80084,corn:21e6,swell:1923},de=e=>e===h.prod?i.ethereum:i.holesky,ye=e=>e===h.prod?i.binanceSmartChain:i.binanceSmartChainTestnet,ce=e=>e===h.prod?i.base:i.baseTestnet,Y=h.prod,u="0x0000000000000000000000000000000000000000",_e={baseApiUrl:"https://staging.prod.lombard.finance"},Ce={baseApiUrl:"https://gastald-testnet.prod.lombard.finance"},Ie={baseApiUrl:"https://mainnet.prod.lombard.finance"},A=(e=Y)=>{switch(e){case h.prod:return Ie;case h.testnet:return Ce;default:return _e}};function v(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?De(e):Ne(e)}function De(e){return e.response?e.response.data.message:e.message}function Ne(e){return e!=null&&e.message?e.message:"Unknown error"}const _={eth:"DESTINATION_BLOCKCHAIN_ETHEREUM",base:"DESTINATION_BLOCKCHAIN_BASE",bsc:"DESTINATION_BLOCKCHAIN_BSC",mantle:"DESTINATION_BLOCKCHAIN_MANTLE",linea:"DESTINATION_BLOCKCHAIN_LINEA",zcircuit:"DESTINATION_BLOCKCHAIN_ZIRCUIT",scroll:"DESTINATION_BLOCKCHAIN_SCROLL",xlayer:"DESTINATION_BLOCKCHAIN_XLAYER"};function Z(e){switch(e){case i.ethereum:case i.holesky:case i.sepolia:return _.eth;case i.base:case i.baseTestnet:return _.base;case i.binanceSmartChain:case i.binanceSmartChainTestnet:return _.bsc;default:throw new Error(`Unknown chain ID: ${e}`)}}const le="sanctioned_address",xe="api/v1/address/generate",Me="destination address is under sanctions";async function Pe({address:e,chainId:t,signature:n,eip712Data:a,env:s,referrerCode:r,partnerId:o,captchaToken:p}){const{baseApiUrl:y}=A(s),w=Z(t),c={to_address:e,to_address_signature:n,to_chain:w,partner_id:o,nonce:0,captcha:p,referrer_code:r,eip_712_data:a};try{const{data:d}=await S.post(xe,c,{baseURL:y});return d.address}catch(d){const g=v(d);if(Oe(g))return le;throw new Error(g)}}function Oe(e){return!!e.includes(Me)}const Ue="api/v1/address";async function Be({address:e,chainId:t,env:n,partnerId:a}){const s=await me({address:e,chainId:t,env:n,partnerId:a}),r=Fe(s);if(!r)throw new Error("No address");return r.btc_address}function Fe(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 me({address:e,chainId:t,env:n,partnerId:a}){const{baseApiUrl:s}=A(n),r=Z(t),o={to_address:e,to_blockchain:r,limit:1,offset:0,asc:!1,referralId:a},{data:p}=await S.get(Ue,{baseURL:s,params:o});return(p==null?void 0:p.addresses)||[]}const Le=8,K=10**Le;function Q(e){return+e/K}function ke(e){return Math.floor(+e*K)}function be(e,t=Y){switch(e){case _.eth:return de(t);case _.base:return ce(t);case _.bsc:return ye(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||{}),fe=(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))(fe||{});async function Ge({address:e,env:t}){const{baseApiUrl:n}=A(t),{data:a}=await S.get(`api/v1/address/outputs-v2/${e}`,{baseURL:n});return((a==null?void 0:a.outputs)??[]).map(We(t))}function We(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 C(Q(t.value)),address:t.address,chainId:be(t.to_chain,e),claimedTxId: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 Ve=2e-4;async function He({env:e,chainId:t=i.ethereum,amount:n=1}){const{baseApiUrl:a}=A(e),s=Z(t),{data:r}=await S.get(`api/v1/exchange/rate/${s}`,{baseURL:a,params:{amount:n}}),o=new C(Ve).multipliedBy(K).toFixed();return{exchangeRate:+r.amount_out,minAmount:+o}}async function $e({address:e,chainId:t,env:n}){const{baseApiUrl:a}=A(n);try{const{data:s}=await S.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=v(s);throw new Error(r)}}async function qe({userDestinationAddress:e,chainId:t,env:n}){const{baseApiUrl:a}=A(n);try{const{data:s}=await S.get(`${a}/api/v1/claimer/get-user-stake-and-bake-signature`,{params:{userDestinationAddress:e,chainId:t.toString()}});return s}catch(s){const r=v(s);throw new Error(`Failed to get user stake and bake signature: ${r}`)}}async function je({signature:e,typedData:t,address:n,env:a}){const{baseApiUrl:s}=A(a);try{const{data:r}=await S.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=v(r);throw new Error(o)}}async function Je({signature:e,typedData:t,env:n}){const{baseApiUrl:a}=A(n);try{const{data:s}=await S.post(`${a}/api/v1/claimer/save-stake-and-bake-signature`,null,{params:{typed_data:t,signature:e}});return s.status}catch(s){const r=v(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.baseTestnet]:"https://rpc.ankr.com/base_sepolia",[i.binanceSmartChain]:"https://rpc.ankr.com/bsc",[i.binanceSmartChainTestnet]:"https://rpc.ankr.com/bsc_testnet_chapel"};async function Ze(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 C(Number(a))}const Ke=2,ze=25e3;class ee{constructor({chainId:t,rpcUrlConfig:n}){R(this,"chainId");R(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"),Ze(n)]);return!(a!=null&&a.baseFeePerGas)&&typeof(a==null?void 0:a.baseFeePerGas)!="bigint"?{}:{maxFeePerGas:+new C(a.baseFeePerGas.toString(10)).multipliedBy(Ke).plus(s),maxPriorityFeePerGas:+s}}async getSafeGasPriceWei(){const t=await this.getReadWeb3().eth.getGasPrice();return new C(t.toString(10)).plus(ze)}createContract(t,n){const a=this.getReadWeb3();return new a.eth.Contract(t,n)}}class I extends ee{constructor({provider:n,account:a,chainId:s,rpcUrlConfig:r}){super({chainId:s,rpcUrlConfig:r});R(this,"web3");R(this,"account");R(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:y,estimate:w=!1,estimateFee:c=!1,extendedGasLimit:d,gasLimit:g="0",value:N="0",gasLimitMultiplier:Se=1}=s;let{nonce:x}=s;x||(x=await p.eth.getTransactionCount(n)),console.log(`Nonce: ${x}`);const l={from:n,to:a,value:f.utils.numberToHex(N),data:y,nonce:x,chainId:f.utils.numberToHex(r)};if(w)try{const E=await p.eth.estimateGas(l),M=Math.round(Number(E)*Se);d?l.gas=f.utils.numberToHex(M+d):l.gas=f.utils.numberToHex(M)}catch(E){throw new Error(E.message??"Failed to estimate gas limit for transaction.")}else l.gas=f.utils.numberToHex(g);const{maxFeePerGas:ae,maxPriorityFeePerGas:se}=c?await this.getMaxFees().catch(()=>s):s;if(se!==void 0&&(l.maxPriorityFeePerGas=f.utils.numberToHex(se)),ae!==void 0&&(l.maxFeePerGas=f.utils.numberToHex(ae)),!l.maxFeePerGas&&!l.maxPriorityFeePerGas){const E=await this.getSafeGasPriceWei();l.gasPrice=E.toString(10)}if(!l.maxFeePerGas&&!l.maxPriorityFeePerGas){const E=await this.getSafeGasPriceWei();l.gasPrice=E.toString(10)}return console.log("Sending transaction via Web3: ",l),new Promise((E,M)=>{const ie=o.eth.sendTransaction(l);ie.once("transactionHash",async re=>{console.log(`Just signed transaction has is: ${re}`),E({receiptPromise:ie,transactionHash:re})}).catch(M)})}createContract(n,a){return new this.web3.eth.Contract(n,a)}}function Xe(e){switch(e){case i.ethereum:return 1.3;case i.holesky:case i.sepolia:return 1.5;default:return 1.3}}function te(e){return Object.values(i).includes(e)}const Ye={[i.holesky]:"0xED7bfd5C1790576105Af4649817f6d35A75CD818",[i.ethereum]:u,[i.binanceSmartChainTestnet]:"0x731eFa688F3679688cf60A3993b8658138953ED6",[i.binanceSmartChain]:u,[i.sepolia]:"0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",[i.base]:u,[i.baseTestnet]:u,[i.berachainBartioTestnet]:"0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",[i.corn]:u,[i.swell]:u},Qe={[i.holesky]:"0x38A13AB20D15ffbE5A7312d2336EF1552580a4E2",[i.ethereum]:u,[i.binanceSmartChainTestnet]:"0x107Fc7d90484534704dD2A9e24c7BD45DB4dD1B5",[i.binanceSmartChain]:u,[i.sepolia]:"0xc47e4b3124597fdf8dd07843d4a7052f2ee80c30",[i.base]:u,[i.baseTestnet]:u,[i.berachainBartioTestnet]:"0xc47e4b3124597FDF8DD07843D4a7052F2eE80C30",[i.corn]:u,[i.swell]:u},et={[i.ethereum]:"0x8236a87084f8b84306f72007f36f2618a5634494",[i.holesky]:u,[i.sepolia]:u,[i.binanceSmartChainTestnet]:u,[i.binanceSmartChain]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[i.base]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[i.baseTestnet]:u,[i.berachainBartioTestnet]:u,[i.corn]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",[i.swell]:"0xecAc9C5F704e954931349Da37F60E39f515c11c1"};function ne(e=Y){switch(e){case h.prod:return et;case h.testnet:return Qe;default:return Ye}}const tt=[{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"}],nt=[{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"}],at=[{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 st(e){switch(e){case"LBTC":return nt;default:return tt}}function D(e,t){const n=ne(t),{chainId:a}=e;if(!te(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=st("LBTC"),o=e.createContract(r,s);return o.options.address||(o.options.address=s),o}const it="insufficient funds",rt="Insufficient funds for transfer. Make sure you have enough ETH to cover the gas cost.",oe=e=>e.startsWith("0x")?e:"0x"+e;async function ot({data:e,proofSignature:t,env:n,...a}){const s=new I(a),r=D(s,n),o=r.methods.mint(oe(e),oe(t));try{return await s.sendTransactionAsync(s.account,r.options.address,{data:o.encodeABI(),estimate:!0,estimateFee:!0,gasLimitMultiplier:Xe(s.chainId)})}catch(p){console.log("error",p);const y=v(p);throw y.includes(it)?new Error(rt):new Error(y)}}const pt=208,ut=4001,dt=4100,yt=4200,ct=4900,lt=4901,O=-32700,U=-32600,B=-32601,F=-32602,L=-32603,k=-32e3,G=-32001,W=-32002,V=-32003,H=-32004,$=-32005,q=-32006;class he extends Error{constructor(t,n){super(t),Array.isArray(n)?this.cause=new X(n):this.cause=n,this.name=this.constructor.name,typeof Error.captureStackTrace=="function"?Error.captureStackTrace(new.target.constructor):this.stack=new Error().stack}get innerError(){return this.cause instanceof X?this.cause.errors:this.cause}set innerError(t){Array.isArray(t)?this.cause=new X(t):this.cause=t}static convertToString(t,n=!1){if(t==null)return"undefined";const a=JSON.stringify(t,(s,r)=>typeof r=="bigint"?r.toString():r);return n&&["bigint","string"].includes(typeof t)?a.replace(/['\\"]+/g,""):a}toJSON(){return{name:this.name,code:this.code,message:this.message,cause:this.cause,innerError:this.cause}}}class X extends he{constructor(t){super(`Multiple errors occurred: [${t.map(n=>n.message).join("], [")}]`),this.code=pt,this.errors=t}}const mt="An Rpc error has occured with a code of *code*",m={[O]:{message:"Parse error",description:"Invalid JSON"},[U]:{message:"Invalid request",description:"JSON is not a valid request object "},[B]:{message:"Method not found",description:"Method does not exist "},[F]:{message:"Invalid params",description:"Invalid method parameters"},[L]:{message:"Internal error",description:"Internal JSON-RPC error"},[k]:{message:"Invalid input",description:"Missing or invalid parameters"},[G]:{message:"Resource not found",description:"Requested resource not found"},[W]:{message:"Resource unavailable",description:"Requested resource not available"},[V]:{message:"Transaction rejected",description:"Transaction creation failed"},[H]:{message:"Method not supported",description:"Method is not implemented"},[$]:{message:"Limit exceeded",description:"Request exceeds defined limit"},[q]:{message:"JSON-RPC version not supported",description:"Version of JSON-RPC protocol is not supported"},[ut]:{name:"User Rejected Request",message:"The user rejected the request."},[dt]:{name:"Unauthorized",message:"The requested method and/or account has not been authorized by the user."},[yt]:{name:"Unsupported Method",message:"The Provider does not support the requested method."},[ct]:{name:"Disconnected",message:"The Provider is disconnected from all chains."},[lt]:{name:"Chain Disconnected",message:"The Provider is not connected to the requested chain."},"0-999":{name:"",message:"Not used."},1e3:{name:"Normal Closure",message:"The connection successfully completed the purpose for which it was created."},1001:{name:"Going Away",message:"The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection."},1002:{name:"Protocol error",message:"The endpoint is terminating the connection due to a protocol error."},1003:{name:"Unsupported Data",message:"The connection is being terminated because the endpoint received data of a type it cannot accept. (For example, a text-only endpoint received binary data.)"},1004:{name:"Reserved",message:"Reserved. A meaning might be defined in the future."},1005:{name:"No Status Rcvd",message:"Reserved. Indicates that no status code was provided even though one was expected."},1006:{name:"Abnormal Closure",message:"Reserved. Indicates that a connection was closed abnormally (that is, with no close frame being sent) when a status code is expected."},1007:{name:"Invalid frame payload data",message:"The endpoint is terminating the connection because a message was received that contained inconsistent data (e.g., non-UTF-8 data within a text message)."},1008:{name:"Policy Violation",message:"The endpoint is terminating the connection because it received a message that violates its policy. This is a generic status code, used when codes 1003 and 1009 are not suitable."},1009:{name:"Message Too Big",message:"The endpoint is terminating the connection because a data frame was received that is too large."},1010:{name:"Mandatory Ext.",message:"The client is terminating the connection because it expected the server to negotiate one or more extension, but the server didn't."},1011:{name:"Internal Error",message:"The server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request."},1012:{name:"Service Restart",message:"The server is terminating the connection because it is restarting."},1013:{name:"Try Again Later",message:"The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is casting off some of its clients."},1014:{name:"Bad Gateway",message:"The server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code."},1015:{name:"TLS handshake",message:"Reserved. Indicates that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)."},"1016-2999":{name:"",message:"For definition by future revisions of the WebSocket Protocol specification, and for definition by extension specifications."},"3000-3999":{name:"",message:"For use by libraries, frameworks, and applications. These status codes are registered directly with IANA. The interpretation of these codes is undefined by the WebSocket protocol."},"4000-4999":{name:"",message:"For private use, and thus can't be registered. Such codes can be used by prior agreements between WebSocket applications. The interpretation of these codes is undefined by the WebSocket protocol."}};class b extends he{constructor(t,n){super(n??mt.replace("*code*",t.error.code.toString())),this.code=t.error.code,this.id=t.id,this.jsonrpc=t.jsonrpc,this.jsonRpcError=t.error}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{error:this.jsonRpcError,id:this.id,jsonRpc:this.jsonrpc})}}class bt extends b{constructor(t){super(t,m[O].message),this.code=O}}class Tt extends b{constructor(t){super(t,m[U].message),this.code=U}}class ft extends b{constructor(t){super(t,m[B].message),this.code=B}}class ht extends b{constructor(t){super(t,m[F].message),this.code=F}}class gt extends b{constructor(t){super(t,m[L].message),this.code=L}}class wt extends b{constructor(t){super(t,m[k].message),this.code=k}}class Et extends b{constructor(t){super(t,m[H].message),this.code=H}}class At extends b{constructor(t){super(t,m[W].message),this.code=W}}class St extends b{constructor(t){super(t,m[G].message),this.code=G}}class vt extends b{constructor(t){super(t,m[q].message),this.code=q}}class Rt extends b{constructor(t){super(t,m[V].message),this.code=V}}class _t extends b{constructor(t){super(t,m[$].message),this.code=$}}const T=new Map;T.set(O,{error:bt});T.set(U,{error:Tt});T.set(B,{error:ft});T.set(F,{error:ht});T.set(L,{error:gt});T.set(k,{error:wt});T.set(H,{error:Et});T.set(W,{error:At});T.set(V,{error:Rt});T.set(G,{error:St});T.set(q,{error:vt});T.set($,{error:_t});const Ct=e=>typeof e=="string"&&/^((-)?0x[0-9a-f]+|(0x))$/i.test(e);var j;(function(e){e.NUMBER="NUMBER_NUMBER",e.HEX="NUMBER_HEX",e.STR="NUMBER_STR",e.BIGINT="NUMBER_BIGINT"})(j||(j={}));var J;(function(e){e.HEX="BYTES_HEX",e.UINT8ARRAY="BYTES_UINT8ARRAY"})(J||(J={}));j.BIGINT,J.HEX;j.HEX,J.HEX;var pe;(function(e){e.EARLIEST="earliest",e.LATEST="latest",e.PENDING="pending",e.SAFE="safe",e.FINALIZED="finalized"})(pe||(pe={}));var ue;(function(e){e.chainstart="chainstart",e.frontier="frontier",e.homestead="homestead",e.dao="dao",e.tangerineWhistle="tangerineWhistle",e.spuriousDragon="spuriousDragon",e.byzantium="byzantium",e.constantinople="constantinople",e.petersburg="petersburg",e.istanbul="istanbul",e.muirGlacier="muirGlacier",e.berlin="berlin",e.london="london",e.altair="altair",e.arrowGlacier="arrowGlacier",e.grayGlacier="grayGlacier",e.bellatrix="bellatrix",e.merge="merge",e.capella="capella",e.shanghai="shanghai"})(ue||(ue={}));function It(e,t){if(!t)throw new Error("The address for bascule module is not defined");const n=e.createContract(at,t);return n.options.address||(n.options.address=t),n}const Dt="No deposit ID provided. Please provide a deposit ID as an argument.",Nt="Invalid deposit ID. Expected a 0x-prefixed 32-byte hex string.";var ge=(e=>(e[e.UNREPORTED=0]="UNREPORTED",e[e.REPORTED=1]="REPORTED",e[e.WITHDRAWN=2]="WITHDRAWN",e))(ge||{});async function xt({txId:e,env:t,...n}){if(!e)throw new Error(Dt);if(!Ct(e))throw new Error(Nt);const a=new I(n),r=await D(a,t).methods.Bascule().call();if(r===u)return 1;const o=It(a,r);try{const p=await o.methods.depositHistory(Buffer.from(e.replace(/^0x/,""),"hex")).call();return Number(p)}catch(p){const y=v(p);throw new Error(y)}}const Mt=[i.ethereum,i.base,i.binanceSmartChain],we=e=>Mt.includes(e)?h.prod:h.stage;function Ee(e,t){if(!te(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 Pt({chainId:e,rpcUrl:t}){const n=Ee(e,t),a=new ee({chainId:e,rpcUrlConfig:n}),s=we(e),o=await D(a,s).methods.getMintFee().call();return new C(Q(o.toString(10)))}async function Ot(e){const t=new I(e),n=`destination chain id is ${e.chainId}`;return t.signMessage(n)}const Ut=24*60*60;function Bt({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 Ft="Failed to obtain a valid signature. The response is undefined or invalid.",Lt=()=>Math.floor(Date.now()/1e3+Ut);async function kt({address:e,provider:t,fee:n,chainId:a,env:s,expiry:r=Lt()}){var d,g;const o=new I({provider:t,account:e,chainId:a}),y=D(o,s).options.address,w=JSON.stringify(Bt({chainId:a,verifyingContract:y,fee:n,expiry:r})),c=await((g=(d=o.web3)==null?void 0:d.currentProvider)==null?void 0:g.request({method:"eth_signTypedData_v4",params:[e,w]}));if(typeof c=="string")return{signature:c,typedData:w};if(!(c!=null&&c.result))throw new Error(Ft);return{signature:c.result,typedData:w}}const z={[i.holesky]:"0x52BD640617eeD47A00dA0da93351092D49208d1d"},Gt=Object.keys(z).map(Number),Wt=e=>z[e];async function Vt({owner:e,rpcUrl:t,chainId:n}){const a=Ee(n,t),s=new ee({chainId:n,rpcUrlConfig:a}),r=we(n),o=D(s,r);try{return(await o.methods.nonces(e).call()).toString()}catch(p){const y=v(p);throw new Error(y)}}async function Ae({chainId:e,expiry:t,owner:n,spender:a,value:s,rpcUrl:r,verifyingContract:o}){const p=await Vt({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 Ht=e=>{const n=ne("stage")[e];if(!n)throw new Error(`No LBTC contract address configured for chain ID ${e}`);return n},$t="Failed to obtain a valid signature. The response is undefined or invalid.";async function qt({address:e,provider:t,chainId:n,value:a,expiry:s,rpcUrl:r,spender:o}){var g,N;const p=new I({provider:t,account:e,chainId:n}),y=Ht(n),w=await Ae({chainId:n,expiry:s,owner:e,spender:o,value:a,rpcUrl:r,verifyingContract:y}),c=JSON.stringify(w),d=await((N=(g=p.web3)==null?void 0:g.currentProvider)==null?void 0:N.request({method:"eth_signTypedData_v4",params:[e,c]}));if(typeof d=="string")return{signature:d,typedData:c};if(!(d!=null&&d.result))throw new Error($t);return{signature:d.result,typedData:c}}const jt=e=>{const t=z[e];if(!t)throw new Error(`No spender address configured for chain ID ${e}`);return t};exports.BasculeDepositStatus=ge;exports.ENotarizationStatus=Te;exports.ESessionState=fe;exports.OChainId=i;exports.OEnv=h;exports.SANCTIONED_ADDRESS=le;exports.SATOSHI_SCALE=K;exports.STAKE_AND_BAKE_SPENDER_CONTRACTS=z;exports.SUPPORTED_STAKE_AND_BAKE_CHAINS=Gt;exports.claimLBTC=ot;exports.fromSatoshi=Q;exports.generateDepositBtcAddress=Pe;exports.getApiConfig=A;exports.getBasculeDepositStatus=xt;exports.getBaseNetworkByEnv=ce;exports.getBscNetworkByEnv=ye;exports.getChainIdByName=be;exports.getChainNameById=Z;exports.getDepositBtcAddress=Be;exports.getDepositBtcAddresses=me;exports.getDepositsByAddress=Ge;exports.getEthNetworkByEnv=de;exports.getLBTCExchangeRate=He;exports.getLBTCMintingFee=Pt;exports.getLbtcAddressConfig=ne;exports.getNetworkFeeSignature=$e;exports.getStakeAndBakeSpenderAddress=jt;exports.getStakeAndBakeSpenderContract=Wt;exports.getStakeAndBakeTypedData=Ae;exports.getUserStakeAndBakeSignature=qe;exports.isValidChain=te;exports.signLbtcDestionationAddr=Ot;exports.signNetworkFee=kt;exports.signStakeAndBake=qt;exports.storeNetworkFeeSignature=je;exports.storeStakeAndBakeSignature=Je;exports.toSatoshi=ke;
|
|
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 D=(e,t,n)=>(ye(e,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("axios"),_=require("bignumber.js"),f=require("web3"),de=require("@bitcoin-js/tiny-secp256k1-asmjs"),I=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),c={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===c.prod?i.ethereum:i.holesky,z=e=>e===c.prod?i.binanceSmartChain:i.binanceSmartChainTestnet,J=e=>e===c.prod?i.base:i.baseSepoliaTestnet,k=c.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"},w=(e=k)=>{switch(e){case c.prod:return fe;case c.testnet:return be;default:return me}};function v(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 h={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 h.eth;case i.base:case i.baseSepoliaTestnet:return h.base;case i.binanceSmartChain:case i.binanceSmartChainTestnet:return h.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}=w(s),m=P(t),b={to_address:e,to_address_signature:n,to_chain:m,partner_id:o,nonce:0,captcha:p,referrer_code:r,eip_712_data:a,sb_signature_data:u};try{const{data:d}=await A.post(he,b,{baseURL:T});return d.address}catch(d){const C=v(d);if(ve(C))return X;throw new Error(C)}}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}=w(n),r=P(t),o={to_address:e,to_blockchain:r,limit:1,offset:0,asc:!1,referralId:a},{data:p}=await A.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 h.eth:case h.ethOld:return q(t);case h.base:case h.baseOld:return J(t);case h.bsc:case h.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}=w(t),{data:a}=await A.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 _(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}=w(e),s=P(t),{data:r}=await A.get(`api/v1/exchange/rate/${s}`,{baseURL:a,params:{amount:n}}),o=new _(xe).multipliedBy(O).toFixed();return{exchangeRate:+r.amount_out,minAmount:+o}}async function Re({address:e,chainId:t,env:n}){const{baseApiUrl:a}=w(n);try{const{data:s}=await A.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=v(s);throw new Error(r)}}async function Ne({userDestinationAddress:e,chainId:t,env:n}){const{baseApiUrl:a}=w(n);try{const{data:s}=await A.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=v(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}=w(a);try{const{data:r}=await A.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=v(r);throw new Error(o)}}async function Oe({signature:e,typedData:t,env:n}){const{baseApiUrl:a}=w(n);try{const{data:s}=await A.post(`${a}/api/v1/claimer/save-stake-and-bake-signature`,null,{params:{typed_data:t,signature:e}});return s.status}catch(s){const r=v(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 _(Number(a))}const ke=2,Fe=25e3;class B{constructor({chainId:t,rpcUrlConfig:n}){D(this,"chainId");D(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 _(a.baseFeePerGas.toString(10)).multipliedBy(ke).plus(s),maxPriorityFeePerGas:+s}}async getSafeGasPriceWei(){const t=await this.getReadWeb3().eth.getGasPrice();return new _(t.toString(10)).plus(Fe)}createContract(t,n){const a=this.getReadWeb3();return new a.eth.Contract(t,n)}}class E extends B{constructor({provider:n,account:a,chainId:s,rpcUrlConfig:r}){super({chainId:s,rpcUrlConfig:r});D(this,"web3");D(this,"account");D(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:m=!1,extendedGasLimit:b,gasLimit:d="0",value:C="0",gasLimitMultiplier:x=1}=s;let{nonce:M}=s;M||(M=await p.eth.getTransactionCount(n)),console.log(`Nonce: ${M}`);const l={from:n,to:a,value:f.utils.numberToHex(C),data:u,nonce:M,chainId:f.utils.numberToHex(r)};if(T)try{const g=await p.eth.estimateGas(l),R=Math.round(Number(g)*x);b?l.gas=f.utils.numberToHex(R+b):l.gas=f.utils.numberToHex(R)}catch(g){throw new Error(g.message??"Failed to estimate gas limit for transaction.")}else l.gas=f.utils.numberToHex(d);const{maxFeePerGas:H,maxPriorityFeePerGas:$}=m?await this.getMaxFees().catch(()=>s):s;if($!==void 0&&(l.maxPriorityFeePerGas=f.utils.numberToHex($)),H!==void 0&&(l.maxFeePerGas=f.utils.numberToHex(H)),!l.maxFeePerGas&&!l.maxPriorityFeePerGas){const g=await this.getSafeGasPriceWei();l.gasPrice=g.toString(10)}if(!l.maxFeePerGas&&!l.maxPriorityFeePerGas){const g=await this.getSafeGasPriceWei();l.gasPrice=g.toString(10)}return console.log("Sending transaction via Web3: ",l),new Promise((g,R)=>{const K=o.eth.sendTransaction(l);K.once("transactionHash",async Z=>{console.log(`Just signed transaction has is: ${Z}`),g({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 c.prod:return We;case c.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 S(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 E(a),r=S(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 E(a),r=S(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=v(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 E(n),r=await S(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=v(p);throw new Error(u)}}const Ye=[i.ethereum,i.base,i.binanceSmartChain],ae=e=>Ye.includes(e)?c.prod:c.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 S(a,s).methods.getMintFee().call();return new _(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 S(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=S(s,r);try{return(await o.methods.nonces(e).call()).toString()}catch(p){const u=v(p);throw new Error(u)}}async function tt(e){const t=new E(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 b,d;const o=new E({provider:t,account:e,chainId:a}),u=S(o,s).options.address,T=JSON.stringify(at({chainId:a,verifyingContract:u,fee:n,expiry:r})),m=await((d=(b=o.web3)==null?void 0:b.currentProvider)==null?void 0:d.request({method:"eth_signTypedData_v4",params:[e,T]}));if(typeof m=="string")return{signature:m,typedData:T};if(!(m!=null&&m.result))throw new Error(st);return{signature:m.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=>{const n=G("stage")[e];if(!n)throw new Error(`No LBTC contract address configured for chain ID ${e}`);return n},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}){var C,x;const p=new E({provider:t,account:e,chainId:n}),u=pt(n),T=oe(n,o),m=await pe({chainId:n,expiry:s,owner:e,spender:T,value:a,rpcUrl:r,verifyingContract:u}),b=JSON.stringify(m),d=await((x=(C=p.web3)==null?void 0:C.currentProvider)==null?void 0:x.request({method:"eth_signTypedData_v4",params:[e,b]}));if(typeof d=="string")return{signature:d,typedData:b};if(!(d!=null&&d.result))throw new Error(ut);return{signature:d.result,typedData:b}}I.initEccLib(ce);function dt(e,t=c.prod){var r;const n=lt(e),s=(r=I.payments[n]({address:e,network:t===c.prod?I.networks.bitcoin:I.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=I.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 E(a),r=S(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=c;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=w;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;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|