@bestinslot/wallet-kit 0.15.0 → 0.16.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.
@@ -6,6 +6,7 @@ import { OrdinalUtxoInfo } from './helpers';
6
6
  import { Buffer } from 'node:buffer';
7
7
  import { WalletInfo } from '../types/wallet';
8
8
  import * as bitcoinjs from 'bitcoinjs-lib';
9
+ export declare const ENABLE_RBF_NO_LOCKTIME = 4294967293;
9
10
  /** Fee rates are sat/vB and may be fractional; every fee built from one is rounded up to whole sats. */
10
11
  export declare function assertFeeRate(feeRate: number): void;
11
12
  export declare function getDustValue(wallet: WalletInfo): number;
@@ -37,6 +38,7 @@ interface UtxoInfoWithWallet {
37
38
  sequence?: number;
38
39
  finalScriptWitness?: Buffer;
39
40
  }
41
+ export declare const TO_X_ONLY: (pubKey: Buffer) => Buffer<ArrayBufferLike>;
40
42
  /**
41
43
  * Calculate the fees for inscribing multiple inscriptions with the given details, fee rate, postage, payment address, and payment amount.
42
44
  *
@@ -248,15 +250,6 @@ export declare function resolveReclaimInputs(reclaimInscriptions: {
248
250
  * @returns an object containing the built transaction and the fee paid for the transaction
249
251
  */
250
252
  export declare function buildTransactionMultiOutput(utxoArray: UtxoInfo[], forceInUtxos: UtxoInfoWithWallet[], payerWallet: WalletInfo, outputWallets: WalletInfo[], amounts: number[], changeWallet: WalletInfo, feeRate: number, fundingInput?: boolean): BuildTransactionResult;
251
- interface SendMultiInscriptionWithBufferResult {
252
- txid: string;
253
- signed_tx_hex: string;
254
- output_utxos: string[];
255
- output_values: number[];
256
- buffer_utxo: string;
257
- buffer_output_value: number;
258
- }
259
- export declare function sendMultiInscriptionWithBuffer(inscriptionIds: string[], targetPostages: number[], targetAddr: string, bufferValue: number, feeRate: number, paymentAddr: string | null, payment: number | null, dryRun: boolean): Promise<SendMultiInscriptionWithBufferResult>;
260
253
  /**
261
254
  * Sends an inscription to a target address with specified postage and fee rate. This function is used for sending a single inscription, but it can also be used for batch sending by calling it multiple times with different inscription IDs and the same target address.
262
255
  *
@@ -270,6 +263,22 @@ export declare function sendMultiInscriptionWithBuffer(inscriptionIds: string[],
270
263
  * @returns an object containing the transaction ID, signed transaction hex, vout index of the output containing the inscription, and the value of the output containing the inscription
271
264
  */
272
265
  export declare function sendInscriptionAll(inscriptionId: string, targetWallet: WalletInfo, targetPostage: number | null, feeRate: number, dryRun: boolean, signFunc: SignFunction): Promise<SendInscriptionResult>;
266
+ /**
267
+ * Sends the inscription on the first sat of `inscriptionDetails.satpoint`'s output, held at the
268
+ * connected ordinals address, to a target address. That output is input 0 and the target's output
269
+ * is output 0; cardinal UTXOs of the payment address pay the fee, and every input signals RBF. The
270
+ * output is spent as given, so the send can replace a mempool transaction spending it.
271
+ *
272
+ * @param inscriptionDetails - the inscription's satpoint (`<txid>:<vout>:0`), output value and script type
273
+ * @param targetWallet - the wallet to send the inscription to (only the address field is used)
274
+ * @param targetPostage - the target output's value; the target's dust value when null or not positive
275
+ * @param feeRate - the fee rate in sat/vbyte to use for the transaction
276
+ * @param dryRun - if true, the transaction is not broadcast
277
+ * @param signFunc - the function that signs the transaction
278
+ *
279
+ * @returns the transaction ID, signed transaction hex, the inscription's vout and that output's value
280
+ */
281
+ export declare function sendInscriptionUtxoAll(inscriptionDetails: Pick<InscriptionUTXODetails, 'satpoint' | 'value' | 'script_type'>, targetWallet: WalletInfo, targetPostage: number | null, feeRate: number, dryRun: boolean, signFunc: SignFunction): Promise<SendInscriptionResult>;
273
282
  export interface InscriptionUTXODetails {
274
283
  satpoint: string;
275
284
  value: number;
@@ -283,20 +292,6 @@ export interface InscriptionUTXODetails {
283
292
  * chain provider).
284
293
  */
285
294
  export declare function getInscriptionDetails(inscriptionId: string, inscriptionAddr: string, ordinalUtxos?: OrdinalUtxoInfo[]): Promise<InscriptionUTXODetails | null>;
286
- /**
287
- * Sends multiple inscriptions in one transaction with a buffer output and returns the fee paid for the transaction. This is used for batch minting or batch sending when the user wants to know the fee before actually sending the transaction.
288
- *
289
- * @param inscriptionIds - array of inscription IDs to send
290
- * @param targetPostages - array of target postages for each inscription
291
- * @param targetAddr - address to send the inscriptions to
292
- * @param bufferValue - value of the buffer output
293
- * @param feeRate - fee rate in sat/vbyte
294
- * @param paymentAddr - address to send the payment to (if payment is not null)
295
- * @param payment - amount to pay (if payment is not null)
296
- *
297
- * @returns the fee paid for the transaction in satoshis
298
- */
299
- export declare function getMultiInscriptionWithBufferFeeRate(inscriptionIds: string[], targetPostages: number[], targetAddr: string, bufferValue: number, feeRate: number, paymentAddr: string | null, payment: number | null): Promise<number>;
300
295
  /**
301
296
  * Mints an inscription by building and signing the commit and reveal transactions. The commit transaction is built using the buildCommitTx function, and the reveal transaction is built using the buildRevealTx function. The function also validates the transactions before broadcasting them to the network. If dryRun is true, the transactions will not be broadcasted and the signed transaction hex will be returned for inspection.
302
297
  *
@@ -318,6 +313,8 @@ export declare function mintAll(inscriptionDetails: InscriptionDetails, feeRate:
318
313
  inscription_id: string;
319
314
  postage: number;
320
315
  secret: string;
316
+ commit_fee: number;
317
+ reveal_fee: number;
321
318
  }>;
322
319
  /**
323
320
  * Mints an inscription using the connected payment wallet for both the commit and reveal transactions. This function is a wrapper around the mintAll function that simplifies the minting process when the user wants to use the same wallet for both transactions. It retrieves the connected wallets, builds and signs the transactions, validates them, and broadcasts them to the network. If dryRun is true, it returns the signed transaction hex without broadcasting.
@@ -120,12 +120,3 @@ export declare function signMessageLocalVerifyDeterministic(message: string): Pr
120
120
  * @returns The transaction ID of the sent transaction.
121
121
  */
122
122
  export declare function sendBTC(amountSats: number, toAddress: string, feeRate?: number): Promise<string>;
123
- /**
124
- * Signs a PSBT using the currently connected wallet provider.
125
- *
126
- * @param psbtBase64 The PSBT to sign, base64-encoded.
127
- * @param broadcast Whether to broadcast the signed transaction.
128
- * @param inputsToSign The inputs to sign.
129
- * @param message Optional message passed to providers that support it (ignored by others).
130
- */
131
- export declare function signPSBT(psbtBase64: string, broadcast: boolean, inputsToSign: any[], message?: string): Promise<void>;
@@ -0,0 +1,36 @@
1
+ import { Buffer } from 'node:buffer';
2
+ /**
3
+ * The fields of a transfer between swap wallets that both signatures cover.
4
+ */
5
+ export interface TransferOrderFields {
6
+ /** The recipient's BTC (ordinals) address, as their swap wallet is registered with the backend. */
7
+ toBtcAddress: string;
8
+ tokenAddress: string;
9
+ amt: bigint;
10
+ btcFee: bigint;
11
+ }
12
+ /** keccak256 of a 256-byte BLS pubkey, the key the swap contract holds balances under; 0x-prefixed. */
13
+ export declare function swapPubkeyHash(pubkey: string): string;
14
+ /**
15
+ * The text the ordinals wallet signs (BIP-322) for a transfer order. It names the recipient by BTC
16
+ * address, which is what the user typed; the backend resolves it to the recipient's swap wallet.
17
+ */
18
+ export declare function transferOrderSignatureText(order: TransferOrderFields): string;
19
+ export interface TransferBLSMessageFields {
20
+ /** block.chainid of the BRC2.0 EVM the swap contract runs on. */
21
+ chainId: bigint;
22
+ contractAddress: string;
23
+ fromPubkey: string;
24
+ nonce: bigint;
25
+ tokenAddress: string;
26
+ toPubkey: string;
27
+ amt: bigint;
28
+ btcFee: bigint;
29
+ }
30
+ /**
31
+ * The message the swap key signs for a transfer, as the contract's `transferMessage` packs it:
32
+ * "BIS_SWAP_TRANSFER", chain id (32 bytes), contract (20), sender pubkey hash (32), pk nonce (4),
33
+ * selector 0x08 (1), token (20), recipient pubkey hash (32), amount (32), fee (32). The chain id and
34
+ * contract bind the signature to one deployment.
35
+ */
36
+ export declare function transferBLSMessage(f: TransferBLSMessageFields): Buffer;
@@ -23,18 +23,16 @@ export declare function saveInfo(wbtcAddr: string, factory: string): void;
23
23
  */
24
24
  export declare function calculatePairAddress(tokenAAddr: string, tokenBAddr: string): string;
25
25
  /**
26
- * Handles the add liquidity request for a Uniswap-like decentralized exchange. The addLiquidityRequest function takes various parameters including the user's public key, token addresses, amounts, minimum amounts, fees, and a BLS signature for authentication. It first checks the validity of the BLS signature to ensure that the request is authorized. Then, it calculates the actual amounts of tokens to be added to the liquidity pool based on the desired amounts and the current reserves. If the signature is valid and the amounts are sufficient, it updates the internal state of balances and reserves accordingly. Finally, it returns a success response with the actual amounts added and liquidity tokens minted, or an error message if any step fails.
26
+ * Handles the add liquidity request for a Uniswap-like decentralized exchange. The addLiquidityRequest function takes various parameters including the user's public key, token addresses, amounts, minimum amounts, fees. It calculates the actual amounts of tokens to be added to the liquidity pool based on the desired amounts and the current reserves. If the amounts are sufficient, it updates the internal state of balances and reserves accordingly. Finally, it returns a success response with the actual amounts added and liquidity tokens minted, or an error message if any step fails.
27
27
  *
28
28
  * @param proxy An instance of UniswapInfoProxy that provides methods to fetch balances and reserves. This proxy is used to interact with the underlying data source for token balances and liquidity pool reserves, allowing the function to perform necessary calculations and updates based on the current state of the Uniswap-like exchange.
29
- * @param pubkey The user's public key as a hexadecimal string. This public key is used to identify the user making the add liquidity request and to verify the BLS signature for authentication. The function will use this public key to fetch the user's current balances and to update them after successfully adding liquidity.
29
+ * @param pubkey The user's public key as a hexadecimal string. This public key is used to identify the user making the add liquidity request. The function will use this public key to fetch the user's current balances and to update them after successfully adding liquidity.
30
30
  * @param token1Addr The address of the first token in the liquidity pair as a hexadecimal string. This address is used to identify the token being added to the liquidity pool and to fetch its current balance and reserves. The function will also use this address to calculate the pair address and to update the user's balance after adding liquidity.
31
31
  * @param token2Addr The address of the second token in the liquidity pair as a hexadecimal string. Similar to token1Addr, this address is used to identify the second token being added to the liquidity pool, to fetch its current balance and reserves, and to calculate the pair address for updating the user's balance after adding liquidity.
32
32
  * @param amt1 The desired amount of the first token to be added to the liquidity pool as a bigint. This amount is used in the calculation of how much of each token will actually be added based on the current reserves and the desired amounts. The function will ensure that this amount meets the minimum requirements and will update the user's balance accordingly after adding liquidity.
33
33
  * @param amt2 The desired amount of the second token to be added to the liquidity pool as a bigint. Similar to amt1, this amount is used in the calculation of how much of each token will actually be added based on the current reserves and the desired amounts. The function will ensure that this amount meets the minimum requirements and will update the user's balance accordingly after adding liquidity.
34
34
  * @param minamt1 The minimum acceptable amount of the first token to be added to the liquidity pool as a bigint. This parameter is used to ensure that the user receives at least this amount of the first token when adding liquidity, even if the actual amount calculated based on the desired amounts and current reserves is higher. If the calculated amount of the first token is less than this minimum, the function will throw an error and not proceed with adding liquidity.
35
35
  * @param minamt2 The minimum acceptable amount of the second token to be added to the liquidity pool as a bigint. Similar to minamt1, this parameter is used to ensure that the user receives at least this amount of the second token when adding liquidity. If the calculated amount of the second token is less than this minimum, the function will throw an error and not proceed with adding liquidity.
36
- * @param blsSignature The BLS signature as a hexadecimal string that is used to authenticate the add liquidity request. This signature is generated by the user using their private key and is verified against the public key and the message constructed from the request parameters. The function will check the validity of this signature before proceeding with adding liquidity, ensuring that only authorized requests are processed.
37
- * @param nonce A unique nonce as a bigint that is used in the construction of the message for BLS signature verification. This nonce helps to prevent replay attacks by ensuring that each add liquidity request has a unique message, even if all other parameters are the same. The function will include this nonce in the message that is hashed and verified against the BLS signature to ensure the authenticity of the request.
38
36
  * @param token1FeeBps The fee for the first token in basis points (bps) as a bigint. This fee is applied to the amount of the first token being added to the liquidity pool and is deducted from the user's balance. The function will calculate the fee based on this value and ensure that it is properly accounted for in the user's balance updates after adding liquidity.
39
37
  * @param token2FeeBps The fee for the second token in basis points (bps) as a bigint. Similar to token1FeeBps, this fee is applied to the amount of the second token being added to the liquidity pool and is deducted from the user's balance. The function will calculate the fee based on this value and ensure that it is properly accounted for in the user's balance updates after adding liquidity.
40
38
  * @param btcFee The fee in BTC as a bigint that is applied to the add liquidity request. This fee is deducted from the user's balance in WBTC and is used to cover the costs associated with processing the request. The function will ensure that this fee is properly accounted for in the user's balance updates after adding liquidity.
@@ -48,8 +46,6 @@ amt1: bigint, // bigint token1 amount
48
46
  amt2: bigint, // bigint token2 amount
49
47
  minamt1: bigint, // bigint min token1 amount
50
48
  minamt2: bigint, // bigint min token2 amount
51
- blsSignature: string, // hex string BLS signature
52
- nonce: bigint, // unique request nonce
53
49
  token1FeeBps: bigint, // bigint token1 fee in bps
54
50
  token2FeeBps: bigint, // bigint token2 fee in bps
55
51
  btcFee: bigint): Promise<{
@@ -62,17 +58,15 @@ btcFee: bigint): Promise<{
62
58
  error_message?: string;
63
59
  }>;
64
60
  /**
65
- * Handles the remove liquidity request for BiS Swap. The removeLiquidityRequest function takes various parameters including the user's public key, token addresses, liquidity amount, minimum amounts, fees, and a BLS signature for authentication. It first checks the validity of the BLS signature to ensure that the request is authorized. Then, it verifies that the user has sufficient liquidity balance to burn. If the signature is valid and the balance is sufficient, it calculates the actual amounts of tokens to be removed from the liquidity pool based on the liquidity amount and current reserves. Finally, it updates the internal state of balances and reserves accordingly and returns a success response with the actual amounts removed, or an error message if any step fails.
61
+ * Handles the remove liquidity request for BiS Swap. The removeLiquidityRequest function takes various parameters including the user's public key, token addresses, liquidity amount, minimum amounts, fees. It verifies that the user has sufficient liquidity balance to burn. If the balance is sufficient, it calculates the actual amounts of tokens to be removed from the liquidity pool based on the liquidity amount and current reserves. Finally, it updates the internal state of balances and reserves accordingly and returns a success response with the actual amounts removed, or an error message if any step fails.
66
62
  *
67
63
  * @param proxy An instance of UniswapInfoProxy that provides methods to fetch balances and reserves. This proxy is used to interact with the underlying data source for token balances and liquidity pool reserves, allowing the function to perform necessary calculations and updates based on the current state of the Uniswap-like exchange.
68
- * @param pubkey The user's public key as a hexadecimal string. This public key is used to identify the user making the remove liquidity request and to verify the BLS signature for authentication. The function will use this public key to fetch the user's current balances and to update them after successfully removing liquidity.
64
+ * @param pubkey The user's public key as a hexadecimal string. This public key is used to identify the user making the remove liquidity request. The function will use this public key to fetch the user's current balances and to update them after successfully removing liquidity.
69
65
  * @param token1Addr The address of the first token in the liquidity pair as a hexadecimal string. This address is used to identify the token being removed from the liquidity pool and to fetch its current balance and reserves. The function will also use this address to calculate the pair address and to update the user's balance after removing liquidity.
70
66
  * @param token2Addr The address of the second token in the liquidity pair as a hexadecimal string. Similar to token1Addr, this address is used to identify the second token being removed from the liquidity pool, to fetch its current balance and reserves, and to calculate the pair address for updating the user's balance after removing liquidity.
71
67
  * @param liquidity The amount of liquidity tokens to be burned as a bigint. This amount is used in the calculation of how much of each underlying token will be removed from the liquidity pool based on the current reserves and total supply. The function will ensure that this amount meets the minimum requirements and will update the user's balance accordingly after removing liquidity.
72
68
  * @param minamt1 The minimum acceptable amount of the first token to be removed from the liquidity pool as a bigint. This parameter is used to ensure that the user receives at least this amount of the first token when removing liquidity, even if the actual amount calculated based on the liquidity burned and current reserves is higher. If the calculated amount of the first token is less than this minimum, the function will throw an error and not proceed with removing liquidity.
73
69
  * @param minamt2 The minimum acceptable amount of the second token to be removed from the liquidity pool as a bigint. Similar to minamt1, this parameter is used to ensure that the user receives at least this amount of the second token when removing liquidity. If the calculated amount of the second token is less than this minimum, the function will throw an error and not proceed with removing liquidity.
74
- * @param blsSignature The BLS signature as a hexadecimal string that is used to authenticate the remove liquidity request. This signature is generated by the user using their private key and is verified against the public key and the message constructed from the request parameters. The function will check the validity of this signature before proceeding with removing liquidity, ensuring that only authorized requests are processed.
75
- * @param nonce A unique nonce as a bigint that is used in the construction of the message for BLS signature verification. This nonce helps to prevent replay attacks by ensuring that each remove liquidity request has a unique message, even if all other parameters are the same. The function will include this nonce in the message that is hashed and verified against the BLS signature to ensure the authenticity of the request.
76
70
  * @param token1FeeBps The fee for the first token in basis points (bps) as a bigint. This fee is applied to the amount of the first token being removed from the liquidity pool and is deducted from the user's balance. The function will calculate the fee based on this value and ensure that it is properly accounted for in the user's balance updates after removing liquidity.
77
71
  * @param token2FeeBps The fee for the second token in basis points (bps) as a bigint. Similar to token1FeeBps, this fee is applied to the amount of the second token being removed from the liquidity pool and is deducted from the user's balance. The function will calculate the fee based on this value and ensure that it is properly accounted for in the user's balance updates after removing liquidity.
78
72
  * @param btcFee The fee in BTC as a bigint that is applied to the remove liquidity request. This fee is deducted from the user's balance in WBTC and is used to cover the costs associated with processing the request. The function will ensure that this fee is properly accounted for in the user's balance updates after removing liquidity.
@@ -85,8 +79,6 @@ token2Addr: string, // hex string token2 address
85
79
  liquidity: bigint, // bigint lp token amount
86
80
  minamt1: bigint, // bigint min token1 amount
87
81
  minamt2: bigint, // bigint min token2 amount
88
- blsSignature: string, // hex string BLS signature
89
- nonce: bigint, // unique request nonce
90
82
  token1FeeBps: bigint, // bigint token1 fee in bps
91
83
  token2FeeBps: bigint, // bigint token2 fee in bps
92
84
  btcFee: bigint): Promise<{
@@ -103,16 +95,14 @@ btcFee: bigint): Promise<{
103
95
  data?: undefined;
104
96
  }>;
105
97
  /**
106
- * Handles the swap request for BiS Swap. The swapRequest function takes various parameters including the user's public key, token addresses, input amount, minimum output amount, fees, and a BLS signature for authentication. It first checks the validity of the BLS signature to ensure that the request is authorized. Then, it verifies that the user has sufficient balance of the input token. If the signature is valid and the balance is sufficient, it calculates the output amount based on the current reserves and the input amount. Finally, it updates the internal state of balances and reserves accordingly and returns a success response with the output amount and price impact, or an error message if any step fails.
98
+ * Handles the swap request for BiS Swap. The swapRequest function takes various parameters including the user's public key, token addresses, input amount, minimum output amount, fees. It verifies that the user has sufficient balance of the input token. If the balance is sufficient, it calculates the output amount based on the current reserves and the input amount. Finally, it updates the internal state of balances and reserves accordingly and returns a success response with the output amount and price impact, or an error message if any step fails.
107
99
  *
108
100
  * @param proxy An instance of UniswapInfoProxy that provides methods to fetch balances and reserves. This proxy is used to interact with the underlying data source for token balances and liquidity pool reserves, allowing the function to perform necessary calculations and updates based on the current state of the Uniswap-like exchange.
109
- * @param pubkey The user's public key as a hexadecimal string. This public key is used to identify the user making the swap request and to verify the BLS signature for authentication. The function will use this public key to fetch the user's current balances and to update them after successfully executing the swap.
101
+ * @param pubkey The user's public key as a hexadecimal string. This public key is used to identify the user making the swap request. The function will use this public key to fetch the user's current balances and to update them after successfully executing the swap.
110
102
  * @param token1Addr The address of the input token as a hexadecimal string. This address is used to identify the token being swapped from and to fetch its current balance and reserves. The function will also use this address to calculate the pair address and to update the user's balance after executing the swap.
111
103
  * @param token2Addr The address of the output token as a hexadecimal string. Similar to token1Addr, this address is used to identify the token being swapped to, to fetch its current balance and reserves, and to calculate the pair address for updating the user's balance after executing the swap.
112
104
  * @param inAmt The amount of the input token to be swapped as a bigint. This amount is used in the calculation of how much of the output token will be received based on the current reserves and the swap formula. The function will ensure that this amount meets the minimum requirements and will update the user's balance accordingly after executing the swap.
113
105
  * @param minOutAmt The minimum acceptable amount of the output token to be received from the swap as a bigint. This parameter is used to ensure that the user receives at least this amount of the output token when executing the swap, even if the actual amount calculated based on the input amount and current reserves is higher. If the calculated amount of the output token is less than this minimum, the function will throw an error and not proceed with executing the swap.
114
- * @param blsSignature The BLS signature as a hexadecimal string that is used to authenticate the swap request. This signature is generated by the user using their private key and is verified against the public key and the message constructed from the request parameters. The function will check the validity of this signature before proceeding with executing the swap, ensuring that only authorized requests are processed.
115
- * @param nonce A unique nonce as a bigint that is used in the construction of the message for BLS signature verification. This nonce helps to prevent replay attacks by ensuring that each swap request has a unique message, even if all other parameters are the same. The function will include this nonce in the message that is hashed and verified against the BLS signature to ensure the authenticity of the request.
116
106
  * @param token1FeeBps The fee for the input token in basis points (bps) as a bigint. This fee is applied to the amount of the input token being swapped and is deducted from the user's balance. The function will calculate the fee based on this value and ensure that it is properly accounted for in the user's balance updates after executing the swap.
117
107
  * @param token2FeeBps The fee for the output token in basis points (bps) as a bigint. This fee is applied to the amount of the output token being received and is deducted from the user's balance. The function will calculate the fee based on this value and ensure that it is properly accounted for in the user's balance updates after executing the swap.
118
108
  * @param btcFee The miner fee as a bigint, denominated in WBTC sats. It is a flat amount, not a rate: the function debits exactly this much WBTC from the user's balance on top of the swap, so it is not reflected in the amounts returned.
@@ -124,8 +114,6 @@ token1Addr: string, // hex string token in address
124
114
  token2Addr: string, // hex string token out address
125
115
  inAmt: bigint, // bigint token in amount
126
116
  minOutAmt: bigint, // bigint min token out amount
127
- blsSignature: string, // hex string BLS signature
128
- nonce: bigint, // unique request nonce
129
117
  token1FeeBps: bigint, // bigint token1 fee in bps
130
118
  token2FeeBps: bigint, // bigint token2 fee in bps
131
119
  btcFee: bigint): Promise<{
@@ -144,16 +132,14 @@ btcFee: bigint): Promise<{
144
132
  reserve_out?: undefined;
145
133
  }>;
146
134
  /**
147
- * Handles the swap request with specified output amount for BiS Swap. The swap2Request function takes various parameters including the user's public key, token addresses, maximum input amount, desired output amount, fees, and a BLS signature for authentication. It first checks the validity of the BLS signature to ensure that the request is authorized. Then, it verifies that the user has sufficient balance of the input token and that the maximum input amount is sufficient to receive the desired output amount based on the current reserves. If the signature is valid and the balance is sufficient, it calculates the actual input amount required to receive the desired output amount based on the current reserves and the swap formula. Finally, it updates the internal state of balances and reserves accordingly and returns a success response with the actual input amount used and price impact, or an error message if any step fails.
135
+ * Handles the swap request with specified output amount for BiS Swap. The swap2Request function takes various parameters including the user's public key, token addresses, maximum input amount, desired output amount, fees. It verifies that the user has sufficient balance of the input token and that the maximum input amount is sufficient to receive the desired output amount based on the current reserves. If the balance is sufficient, it calculates the actual input amount required to receive the desired output amount based on the current reserves and the swap formula. Finally, it updates the internal state of balances and reserves accordingly and returns a success response with the actual input amount used and price impact, or an error message if any step fails.
148
136
  *
149
137
  * @param proxy An instance of UniswapInfoProxy that provides methods to fetch balances and reserves. This proxy is used to interact with the underlying data source for token balances and liquidity pool reserves, allowing the function to perform necessary calculations and updates based on the current state of the Uniswap-like exchange.
150
- * @param pubkey The user's public key as a hexadecimal string. This public key is used to identify the user making the swap request and to verify the BLS signature for authentication. The function will use this public key to fetch the user's current balances and to update them after successfully executing the swap.
138
+ * @param pubkey The user's public key as a hexadecimal string. This public key is used to identify the user making the swap request. The function will use this public key to fetch the user's current balances and to update them after successfully executing the swap.
151
139
  * @param token1Addr The address of the input token as a hexadecimal string. This address is used to identify the token being swapped from and to fetch its current balance and reserves. The function will also use this address to calculate the pair address and to update the user's balance after executing the swap.
152
140
  * @param token2Addr The address of the output token as a hexadecimal string. Similar to token1Addr, this address is used to identify the token being swapped to, to fetch its current balance and reserves, and to calculate the pair address for updating the user's balance after executing the swap.
153
141
  * @param maxInAmt The maximum amount of the input token that the user is willing to swap as a bigint. This amount is used to ensure that the user does not spend more than this amount of the input token when trying to receive the desired output amount. The function will check that the actual input amount required to receive the desired output amount does not exceed this maximum, and if it does, the function will throw an error and not proceed with executing the swap.
154
142
  * @param outAmt The desired amount of the output token to be received from the swap as a bigint. This amount is used in the calculation of how much of the input token will be required based on the current reserves and the swap formula. The function will ensure that this amount meets the minimum requirements and will update the user's balance accordingly after executing the swap.
155
- * @param blsSignature The BLS signature as a hexadecimal string that is used to authenticate the swap request. This signature is generated by the user using their private key and is verified against the public key and the message constructed from the request parameters. The function will check the validity of this signature before proceeding with executing the swap, ensuring that only authorized requests are processed.
156
- * @param nonce A unique nonce as a bigint that is used in the construction of the message for BLS signature verification. This nonce helps to prevent replay attacks by ensuring that each swap request has a unique message, even if all other parameters are the same. The function will include this nonce in the message that is hashed and verified against the BLS signature to ensure the authenticity of the request.
157
143
  * @param token1FeeBps The fee for the input token in basis points (bps) as a bigint. This fee is applied to the amount of the input token being swapped and is deducted from the user's balance. The function will calculate the fee based on this value and ensure that it is properly accounted for in the user's balance updates after executing the swap.
158
144
  * @param token2FeeBps The fee for the output token in basis points (bps) as a bigint. This fee is applied to the amount of the output token being received and is deducted from the user's balance. The function will calculate the fee based on this value and ensure that it is properly accounted for in the user's balance updates after executing the swap.
159
145
  * @param btcFee The miner fee as a bigint, denominated in WBTC sats. It is a flat amount, not a rate: the function debits exactly this much WBTC from the user's balance on top of the swap, so it is not reflected in the amounts returned.
@@ -165,8 +151,6 @@ token1Addr: string, // hex string token in address
165
151
  token2Addr: string, // hex string token out address
166
152
  maxInAmt: bigint, // bigint max token in amount
167
153
  outAmt: bigint, // bigint token out amount
168
- blsSignature: string, // hex string BLS signature
169
- nonce: bigint, // unique request nonce
170
154
  token1FeeBps: bigint, // bigint token1 fee in bps
171
155
  token2FeeBps: bigint, // bigint token2 fee in bps
172
156
  btcFee: bigint): Promise<{
@@ -185,45 +169,12 @@ btcFee: bigint): Promise<{
185
169
  reserve_out?: undefined;
186
170
  }>;
187
171
  /**
188
- * Handles the withdraw request for BiS Swap. The withdrawRequest function takes various parameters including the user's public key, token address, target address, amount to withdraw, fees, and a BLS signature for authentication. It first checks the validity of the BLS signature to ensure that the request is authorized. Then, it verifies that the user has sufficient balance of the specified token to withdraw. If the signature is valid and the balance is sufficient, it updates the internal state of balances accordingly and returns a success response with the withdrawn amount, or an error message if any step fails.
172
+ * Handles the unwrap request for BiS Swap. The unwrapRequest function takes various parameters including the user's public key, pkscript, amount to unwrap, fees. It verifies that the user has sufficient balance of the wrapped token (WBTC) to unwrap. If the balance is sufficient, it updates the internal state of balances accordingly and returns a success response with the unwrapped amount, or an error message if any step fails.
189
173
  *
190
174
  * @param proxy An instance of UniswapInfoProxy that provides methods to fetch balances and reserves. This proxy is used to interact with the underlying data source for token balances and liquidity pool reserves, allowing the function to perform necessary calculations and updates based on the current state of the Uniswap-like exchange.
191
- * @param pubkey The user's public key as a hexadecimal string. This public key is used to identify the user making the withdraw request and to verify the BLS signature for authentication. The function will use this public key to fetch the user's current balances and to update them after successfully executing the withdraw.
192
- * @param tokenAddr The address of the token to be withdrawn as a hexadecimal string. This address is used to identify the token being withdrawn and to fetch its current balance. The function will also use this address to update the user's balance after successfully executing the withdraw.
193
- * @param targetAddr The target address where the withdrawn tokens will be sent as a hexadecimal string. This address is used to specify the destination of the withdrawn tokens. The function will ensure that this address is valid and will include it in the message for BLS signature verification to ensure the authenticity of the request.
194
- * @param amt The amount of the token to be withdrawn as a bigint. This amount is used to check if the user has sufficient balance of the specified token to withdraw. The function will also include this amount in the message for BLS signature verification and will update the user's balance accordingly after successfully executing the withdraw.
195
- * @param blsSignature The BLS signature as a hexadecimal string that is used to authenticate the withdraw request. This signature is generated by the user using their private key and is verified against the public key and the message constructed from the request parameters. The function will check the validity of this signature before proceeding with executing the withdraw, ensuring that only authorized requests are processed.
196
- * @param nonce A unique nonce as a bigint that is used in the construction of the message for BLS signature verification. This nonce helps to prevent replay attacks by ensuring that each withdraw request has a unique message, even if all other parameters are the same. The function will include this nonce in the message that is hashed and verified against the BLS signature to ensure the authenticity of the request.
197
- * @param btcFee The miner fee as a bigint, denominated in WBTC sats. It is a flat amount, not a rate: the function debits exactly this much WBTC from the user's balance on top of the withdraw, so it is not reflected in the amounts returned.
198
- *
199
- * @returns A promise that resolves to an object indicating the success of the operation. If successful, the object contains the amount of the token that was withdrawn. If there is an error, the object contains an error message describing the issue that occurred during the withdraw process.
200
- */
201
- export declare function withdrawRequest(proxy: UniswapInfoProxy, pubkey: string, // hex string bls pubkey
202
- tokenAddr: string, // hex string token address
203
- targetAddr: string, // hex string target address
204
- amt: bigint, // bigint token amount
205
- blsSignature: string, // hex string BLS signature
206
- nonce: bigint, // unique request nonce
207
- btcFee: bigint): Promise<{
208
- success: boolean;
209
- data: {
210
- amt: bigint;
211
- };
212
- error_message?: undefined;
213
- } | {
214
- success: boolean;
215
- error_message: any;
216
- data?: undefined;
217
- }>;
218
- /**
219
- * Handles the unwrap request for BiS Swap. The unwrapRequest function takes various parameters including the user's public key, pkscript, amount to unwrap, fees, and a BLS signature for authentication. It first checks the validity of the BLS signature to ensure that the request is authorized. Then, it verifies that the user has sufficient balance of the wrapped token (WBTC) to unwrap. If the signature is valid and the balance is sufficient, it updates the internal state of balances accordingly and returns a success response with the unwrapped amount, or an error message if any step fails.
220
- *
221
- * @param proxy An instance of UniswapInfoProxy that provides methods to fetch balances and reserves. This proxy is used to interact with the underlying data source for token balances and liquidity pool reserves, allowing the function to perform necessary calculations and updates based on the current state of the Uniswap-like exchange.
222
- * @param pubkey The user's public key as a hexadecimal string. This public key is used to identify the user making the unwrap request and to verify the BLS signature for authentication. The function will use this public key to fetch the user's current balances and to update them after successfully executing the unwrap.
223
- * @param pkscript The pkscript as a hexadecimal string that specifies the script for the unwrapped Bitcoin. This pkscript is used in the construction of the message for BLS signature verification to ensure the authenticity of the request. The function will also use this pkscript to determine the destination of the unwrapped Bitcoin and to include it in the message for signature verification.
224
- * @param amt The amount of the wrapped token (WBTC) to be unwrapped as a bigint. This amount is used to check if the user has sufficient balance of WBTC to unwrap. The function will also include this amount in the message for BLS signature verification and will update the user's balance accordingly after successfully executing the unwrap.
225
- * @param blsSignature The BLS signature as a hexadecimal string that is used to authenticate the unwrap request. This signature is generated by the user using their private key and is verified against the public key and the message constructed from the request parameters. The function will check the validity of this signature before proceeding with executing the unwrap, ensuring that only authorized requests are processed.
226
- * @param nonce A unique nonce as a bigint that is used in the construction of the message for BLS signature verification. This nonce helps to prevent replay attacks by ensuring that each unwrap request has a unique message, even if all other parameters are the same. The function will include this nonce in the message that is hashed and verified against the BLS signature to ensure the authenticity of the request.
175
+ * @param pubkey The user's public key as a hexadecimal string. This public key is used to identify the user making the unwrap request. The function will use this public key to fetch the user's current balances and to update them after successfully executing the unwrap.
176
+ * @param pkscript The pkscript as a hexadecimal string that specifies the script for the unwrapped Bitcoin. The function uses this pkscript to determine the destination of the unwrapped Bitcoin.
177
+ * @param amt The amount of the wrapped token (WBTC) to be unwrapped as a bigint. This amount is used to check if the user has sufficient balance of WBTC to unwrap. The function will update the user's balance accordingly after successfully executing the unwrap.
227
178
  * @param btcFee The miner fee as a bigint, denominated in WBTC sats. It is a flat amount, not a rate: the function debits exactly this much WBTC from the user's balance on top of the unwrap, so it is not reflected in the amounts returned.
228
179
  *
229
180
  * @returns A promise that resolves to an object indicating the success of the operation. If successful, the object contains the amount of the wrapped token that was unwrapped. If there is an error, the object contains an error message describing the issue that occurred during the unwrap process.
@@ -231,8 +182,6 @@ btcFee: bigint): Promise<{
231
182
  export declare function unwrapRequest(proxy: UniswapInfoProxy, pubkey: string, // hex string bls pubkey
232
183
  pkscript: string, // hex string pkscript
233
184
  amt: bigint, // bigint token amount
234
- blsSignature: string, // hex string BLS signature
235
- nonce: bigint, // unique request nonce
236
185
  btcFee: bigint): Promise<{
237
186
  success: boolean;
238
187
  data: {
package/dist/vue.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ref as s, onScopeDispose as u, watch as i } from "vue";
2
- import { f as r, _ as c, m as f } from "./helpers-DhmRTIg0.js";
2
+ import { f as r, _ as c, m as f } from "./helpers-Dho-nzKc.js";
3
3
  function w() {
4
4
  const e = s(r()), t = c((o) => {
5
5
  e.value !== o && (e.value = o);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bestinslot/wallet-kit",
3
3
  "type": "module",
4
- "version": "0.15.0",
4
+ "version": "0.16.0",
5
5
  "private": false,
6
6
  "description": "A lightweight JavaScript library for connecting Bitcoin wallets with a unified API.",
7
7
  "license": "MIT",
@@ -68,19 +68,16 @@
68
68
  "@metamask/multichain-api-client": "^0.12.0",
69
69
  "@noble/curves": "2.0.1",
70
70
  "@noble/hashes": "2.0.1",
71
- "@noble/secp256k1": "^3.0.0",
72
71
  "@wallet-standard/app": "^1.1.1",
73
72
  "@wallet-standard/base": "^1.1.1",
74
73
  "base64-arraybuffer": "^1.0.2",
75
74
  "bip322-js": "^3.0.0",
76
75
  "bitcoinjs-lib": "^6.1.7",
77
76
  "bitcoinjs-message": "^2.2.0",
78
- "cbor2": "^1.12.0",
79
77
  "ecpair": "^3.0.0",
80
78
  "ethers": "^6.16.0",
81
79
  "tiny-secp256k1": "^2.2.4",
82
- "varuint-bitcoin": "^2.0.0",
83
- "web3": "^4.16.0"
80
+ "varuint-bitcoin": "^2.0.0"
84
81
  },
85
82
  "devDependencies": {
86
83
  "@antfu/eslint-config": "^6.7.3",