hodl-wallet 2.0.4 → 2.0.6

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.
Files changed (83) hide show
  1. package/README.md +79 -2
  2. package/dist/agent-cli.js +75 -0
  3. package/dist/agent-cli.js.map +1 -1
  4. package/dist/agent-errors.d.ts +1 -1
  5. package/dist/agent-errors.js.map +1 -1
  6. package/dist/index.js +148 -82
  7. package/dist/index.js.map +1 -1
  8. package/dist/network/arb.d.ts +1 -0
  9. package/dist/network/arb.js +2 -1
  10. package/dist/network/arb.js.map +1 -1
  11. package/dist/network/avax.d.ts +1 -0
  12. package/dist/network/avax.js +2 -1
  13. package/dist/network/avax.js.map +1 -1
  14. package/dist/network/bsc.d.ts +1 -0
  15. package/dist/network/bsc.js +2 -1
  16. package/dist/network/bsc.js.map +1 -1
  17. package/dist/network/eth.d.ts +1 -0
  18. package/dist/network/eth.js +2 -1
  19. package/dist/network/eth.js.map +1 -1
  20. package/dist/network/ftm.d.ts +1 -0
  21. package/dist/network/ftm.js +2 -1
  22. package/dist/network/ftm.js.map +1 -1
  23. package/dist/network/hyperliquid.d.ts +1 -0
  24. package/dist/network/hyperliquid.js +2 -1
  25. package/dist/network/hyperliquid.js.map +1 -1
  26. package/dist/network/lib/BitcoinNetwork.d.ts +2 -0
  27. package/dist/network/lib/BitcoinNetwork.js +23 -15
  28. package/dist/network/lib/BitcoinNetwork.js.map +1 -1
  29. package/dist/network/lib/Web3Network.js +14 -2
  30. package/dist/network/lib/Web3Network.js.map +1 -1
  31. package/dist/network/op.d.ts +1 -0
  32. package/dist/network/op.js +2 -1
  33. package/dist/network/op.js.map +1 -1
  34. package/dist/network/pol.d.ts +1 -0
  35. package/dist/network/pol.js +2 -1
  36. package/dist/network/pol.js.map +1 -1
  37. package/dist/network/types.d.ts +1 -0
  38. package/dist/network-registry.d.ts +1 -0
  39. package/dist/network-registry.js +3 -0
  40. package/dist/network-registry.js.map +1 -1
  41. package/dist/persist.d.ts +2 -0
  42. package/dist/persist.js +21 -0
  43. package/dist/persist.js.map +1 -1
  44. package/dist/profile-lock.d.ts +4 -0
  45. package/dist/profile-lock.js +9 -1
  46. package/dist/profile-lock.js.map +1 -1
  47. package/dist/swap/bitcoin.d.ts +34 -0
  48. package/dist/swap/bitcoin.js +179 -0
  49. package/dist/swap/bitcoin.js.map +1 -0
  50. package/dist/swap/chain.d.ts +49 -0
  51. package/dist/swap/chain.js +255 -0
  52. package/dist/swap/chain.js.map +1 -0
  53. package/dist/swap/config.d.ts +68 -0
  54. package/dist/swap/config.js +46 -0
  55. package/dist/swap/config.js.map +1 -0
  56. package/dist/swap/http.d.ts +14 -0
  57. package/dist/swap/http.js +70 -0
  58. package/dist/swap/http.js.map +1 -0
  59. package/dist/swap/providers.d.ts +24 -0
  60. package/dist/swap/providers.js +424 -0
  61. package/dist/swap/providers.js.map +1 -0
  62. package/dist/swap/routes.d.ts +145 -0
  63. package/dist/swap/routes.js +48 -0
  64. package/dist/swap/routes.js.map +1 -0
  65. package/dist/swap/service.d.ts +104 -0
  66. package/dist/swap/service.js +512 -0
  67. package/dist/swap/service.js.map +1 -0
  68. package/dist/swap/storage.d.ts +3 -0
  69. package/dist/swap/storage.js +28 -0
  70. package/dist/swap/storage.js.map +1 -0
  71. package/dist/swap/types.d.ts +140 -0
  72. package/dist/swap/types.js +2 -0
  73. package/dist/swap/types.js.map +1 -0
  74. package/dist/swap/ui.d.ts +3 -0
  75. package/dist/swap/ui.js +257 -0
  76. package/dist/swap/ui.js.map +1 -0
  77. package/dist/transfer-service.d.ts +38 -0
  78. package/dist/transfer-service.js +181 -0
  79. package/dist/transfer-service.js.map +1 -0
  80. package/dist/wallet-service.d.ts +22 -6
  81. package/dist/wallet-service.js +36 -171
  82. package/dist/wallet-service.js.map +1 -1
  83. package/package.json +99 -92
@@ -0,0 +1,34 @@
1
+ import type { WalletAccount } from '../network/types.js';
2
+ import { BitcoinPayments } from './chain.js';
3
+ import type { ChainReceipt, FundingEstimate, ProviderQuote, SwapChain, SwapInput, SwapPlan, SwapQuote, SwapStep } from './types.js';
4
+ type Output = {
5
+ script: Buffer;
6
+ value: number;
7
+ };
8
+ export declare function bitcoinMemoOutputs(memo?: string): Output[];
9
+ export declare class BitcoinSwapChain extends BitcoinPayments implements SwapChain {
10
+ private readonly network;
11
+ private utxos;
12
+ private feeRate;
13
+ availableBalance(address: string): Promise<bigint>;
14
+ estimate(input: SwapInput, offer: ProviderQuote): Promise<FundingEstimate>;
15
+ balance(input: SwapInput, funding: FundingEstimate): Promise<{
16
+ sufficientAsset: boolean;
17
+ sufficientFee: boolean;
18
+ }>;
19
+ assertAvailable(address: string): Promise<void>;
20
+ checkFunding(quote: SwapQuote): Promise<void>;
21
+ nextStep(): Promise<'deposit'>;
22
+ sign(quote: SwapQuote, plan: SwapPlan, kind: SwapStep['kind'], account: WalletAccount): Promise<SwapStep>;
23
+ broadcast(step: SwapStep): Promise<void>;
24
+ receipt(hash: string): Promise<ChainReceipt>;
25
+ payoutPayment(hash: string, address: string): Promise<{
26
+ amount: bigint;
27
+ confirmations: number;
28
+ }>;
29
+ refundPayment(hash: string, address: string): Promise<{
30
+ amount: bigint;
31
+ confirmations: number;
32
+ }>;
33
+ }
34
+ export {};
@@ -0,0 +1,179 @@
1
+ import * as bitcoin from 'bitcoinjs-lib';
2
+ import BitcoinNetwork, { signBitcoinTransaction } from '../network/lib/BitcoinNetwork.js';
3
+ import { BscPayments, BitcoinPayments } from './chain.js';
4
+ import { swapConfig as config } from './config.js';
5
+ import { integer, list, record, swapJson, swapText, SwapHttpError, textField, transactionHash, units } from './http.js';
6
+ export function bitcoinMemoOutputs(memo) {
7
+ if (memo === undefined)
8
+ return [];
9
+ if (!memo || !/^[\x20-\x7e]+$/.test(memo))
10
+ throw new Error('Invalid Bitcoin swap memo.');
11
+ const bytes = Buffer.from(memo, 'ascii');
12
+ const first = bytes.length <= 80 ? bytes : Buffer.concat([bytes.subarray(0, 79), Buffer.from('^')]);
13
+ const outputs = [{ script: bitcoin.payments.embed({ data: [first] }).output, value: 0 }];
14
+ for (let offset = 79; bytes.length > 80 && offset < bytes.length; offset += 20) {
15
+ const chunk = Buffer.alloc(20);
16
+ bytes.copy(chunk, 0, offset, offset + 20);
17
+ outputs.push({ script: Buffer.concat([Buffer.from('0014', 'hex'), chunk]), value: config.bitcoin.memoDustSats });
18
+ }
19
+ if (outputs.length + 2 > config.bitcoin.maxOutputs)
20
+ throw new Error('Bitcoin swap memo exceeds the supported output limit.');
21
+ return outputs;
22
+ }
23
+ export class BitcoinSwapChain extends BitcoinPayments {
24
+ network = new BitcoinNetwork(config.destination);
25
+ async utxos(address) {
26
+ bitcoin.address.toOutputScript(address, bitcoin.networks.bitcoin);
27
+ const values = list(await swapJson(`${config.destination.url}/address/${address}/utxo`)).map(record);
28
+ const seen = new Set();
29
+ return values.filter(value => record(value.status).confirmed === true).map(value => {
30
+ const input = { txid: transactionHash(value.txid), vout: integer(value.vout), value: integer(value.value) };
31
+ const key = `${input.txid}:${input.vout}`;
32
+ if (seen.has(key) || input.value === 0)
33
+ throw new Error('Invalid Bitcoin UTXO list.');
34
+ seen.add(key);
35
+ return input;
36
+ });
37
+ }
38
+ async feeRate(offer) {
39
+ const estimates = record(await swapJson(`${config.destination.url}/fee-estimates`));
40
+ const value = estimates[String(config.bitcoin.feeTargetBlocks)];
41
+ if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0)
42
+ throw new Error('Invalid Bitcoin fee estimate.');
43
+ const rate = BigInt(Math.ceil(value));
44
+ const recommended = offer?.provider === 'thorchain' ? units(offer.details.gasPrice) : 0n;
45
+ return rate > recommended ? rate : recommended;
46
+ }
47
+ async availableBalance(address) {
48
+ return (await this.utxos(address)).reduce((sum, utxo) => sum + BigInt(utxo.value), 0n);
49
+ }
50
+ async estimate(input, offer) {
51
+ const [utxos, rate] = await Promise.all([this.utxos(input.from), this.feeRate(offer)]);
52
+ const memo = bitcoinMemoOutputs(offer.provider === 'thorchain' ? textField(offer.details.memo) : undefined);
53
+ const memoValue = memo.reduce((sum, output) => sum + BigInt(output.value), 0n);
54
+ const extraBytes = memo.reduce((sum, output) => sum + 8 + 1 + output.script.length, 0);
55
+ const selected = [];
56
+ let value = 0n;
57
+ let size = 0;
58
+ for (const utxo of utxos) {
59
+ selected.push(utxo);
60
+ value += BigInt(utxo.value);
61
+ // SegWit input upper bound, 34-byte deposit script and P2WPKH change.
62
+ size = 11 + selected.length * 69 + 43 + 31 + extraBytes;
63
+ if (value >= BigInt(input.amountBaseUnits) + BigInt(size) * rate + memoValue + BigInt(config.bitcoin.changeDustSats))
64
+ break;
65
+ }
66
+ if (!selected.length)
67
+ throw new Error('No confirmed Bitcoin UTXOs are available.');
68
+ return {
69
+ asset: 'BTC', decimals: 8, price: 'btc', rate: rate.toString(), units: size,
70
+ budgetBaseUnits: (BigInt(size) * rate + memoValue).toString(), inputs: selected
71
+ };
72
+ }
73
+ async balance(input, funding) {
74
+ const available = await this.utxos(input.from);
75
+ const total = available.reduce((sum, utxo) => sum + BigInt(utxo.value), 0n);
76
+ return {
77
+ sufficientAsset: total >= BigInt(input.amountBaseUnits),
78
+ sufficientFee: total >= BigInt(input.amountBaseUnits) + BigInt(funding.budgetBaseUnits) + BigInt(config.bitcoin.changeDustSats)
79
+ };
80
+ }
81
+ async assertAvailable(address) {
82
+ const script = bitcoin.address.toOutputScript(address).toString('hex');
83
+ const pending = list(await swapJson(`${config.destination.url}/address/${address}/txs/mempool`)).map(record);
84
+ if (pending.some(tx => list(tx.vin).some(input => record(record(input).prevout).scriptpubkey === script))) {
85
+ throw new Error('An outgoing Bitcoin transaction is still pending.');
86
+ }
87
+ }
88
+ async checkFunding(quote) {
89
+ const inputs = quote.funding.inputs;
90
+ if (!inputs?.length)
91
+ throw new Error('Bitcoin quote has no selected inputs.');
92
+ const [available, rate] = await Promise.all([this.utxos(quote.from), this.feeRate()]);
93
+ for (const input of inputs) {
94
+ if (!available.some(utxo => utxo.txid === input.txid && utxo.vout === input.vout && utxo.value === input.value)) {
95
+ throw new Error('A selected Bitcoin input is no longer available; obtain a new quote.');
96
+ }
97
+ }
98
+ if (rate > BigInt(quote.funding.rate))
99
+ throw new Error('Bitcoin fee rate increased; obtain a new quote.');
100
+ const total = inputs.reduce((sum, input) => sum + BigInt(input.value), 0n);
101
+ if (total < BigInt(quote.amountBaseUnits) + BigInt(quote.funding.budgetBaseUnits) + BigInt(config.bitcoin.changeDustSats)) {
102
+ throw new Error('Insufficient BTC for the deposit, fee and refund-address change.');
103
+ }
104
+ }
105
+ async nextStep() { return 'deposit'; }
106
+ async sign(quote, plan, kind, account) {
107
+ if (kind !== 'deposit' || quote.routeId !== 'btc-bsc' || plan.router)
108
+ throw new Error('Invalid Bitcoin funding step.');
109
+ const signer = await this.network.privateKeyToAccount(account.privateKey);
110
+ if (signer.address !== quote.from || account.address !== quote.from)
111
+ throw new Error('Swap signer does not match source account.');
112
+ await this.assertAvailable(quote.from);
113
+ await this.checkFunding(quote);
114
+ const inputs = quote.funding.inputs;
115
+ const script = bitcoin.address.toOutputScript(quote.from, bitcoin.networks.bitcoin);
116
+ const psbt = new bitcoin.Psbt({ network: bitcoin.networks.bitcoin });
117
+ psbt.setVersion(2);
118
+ psbt.setLocktime(0);
119
+ let total = 0n;
120
+ for (const input of inputs) {
121
+ const raw = await swapText(`${config.destination.url}/tx/${input.txid}/hex`);
122
+ const parent = bitcoin.Transaction.fromHex(raw.trim());
123
+ const output = parent.outs[input.vout];
124
+ if (parent.getId() !== input.txid || !output || output.value !== input.value || !output.script.equals(script)) {
125
+ throw new Error('Bitcoin funding input does not match the source wallet.');
126
+ }
127
+ if (quote.provider === 'thorchain' && parent.outs.length > config.bitcoin.maxOutputs) {
128
+ throw new Error('THORChain does not accept this Bitcoin parent transaction.');
129
+ }
130
+ psbt.addInput({ hash: input.txid, index: input.vout, nonWitnessUtxo: Buffer.from(raw.trim(), 'hex'), sequence: 0xffffffff });
131
+ total += BigInt(input.value);
132
+ }
133
+ const amount = BigInt(quote.amountBaseUnits);
134
+ const change = total - amount - BigInt(quote.funding.budgetBaseUnits);
135
+ if (amount > BigInt(Number.MAX_SAFE_INTEGER) || change > BigInt(Number.MAX_SAFE_INTEGER) || change < BigInt(config.bitcoin.changeDustSats)) {
136
+ throw new Error('Invalid Bitcoin deposit or change amount.');
137
+ }
138
+ const memo = bitcoinMemoOutputs(quote.provider === 'thorchain' ? textField(plan.memo) : undefined);
139
+ const memoCost = memo.reduce((sum, output) => sum + BigInt(output.value), 0n);
140
+ psbt.addOutput({ address: plan.depositAddress, value: Number(amount) });
141
+ psbt.addOutput({ address: quote.from, value: Number(change) });
142
+ for (const output of memo)
143
+ psbt.addOutput(output);
144
+ signBitcoinTransaction(psbt, account.privateKey, bitcoin.networks.bitcoin);
145
+ const transaction = psbt.extractTransaction();
146
+ const minerFee = BigInt(quote.funding.budgetBaseUnits) - memoCost;
147
+ if (minerFee < BigInt(transaction.virtualSize()) * BigInt(quote.funding.rate)) {
148
+ throw new Error('Bitcoin transaction exceeds the accepted fee budget.');
149
+ }
150
+ return { kind, hash: transaction.getId(), rawTransaction: transaction.toHex(), confirmed: false, broadcastAttempted: false };
151
+ }
152
+ async broadcast(step) {
153
+ const response = await fetch(`${config.destination.url}/tx`, {
154
+ method: 'POST', headers: { 'content-type': 'text/plain' }, body: step.rawTransaction,
155
+ signal: AbortSignal.timeout(config.httpTimeoutMs), redirect: 'error'
156
+ });
157
+ if (!response.ok)
158
+ throw new SwapHttpError(response.status, `Bitcoin broadcast failed (HTTP ${response.status}).`);
159
+ if (transactionHash((await response.text()).trim()) !== step.hash)
160
+ throw new Error('Unexpected Bitcoin broadcast hash.');
161
+ }
162
+ async receipt(hash) {
163
+ try {
164
+ const tx = record(await swapJson(`${config.destination.url}/tx/${transactionHash(hash)}`));
165
+ if (transactionHash(tx.txid) !== transactionHash(hash))
166
+ throw new Error('Bitcoin transaction hash mismatch.');
167
+ const confirmations = await this.confirmations(record(tx.status));
168
+ return { state: confirmations >= config.bitcoinConfirmations ? 'confirmed' : 'pending', confirmations };
169
+ }
170
+ catch (error) {
171
+ if (error instanceof SwapHttpError && error.status === 404)
172
+ return { state: 'not_found', confirmations: 0 };
173
+ throw error;
174
+ }
175
+ }
176
+ async payoutPayment(hash, address) { return new BscPayments().payment(hash, address); }
177
+ async refundPayment(hash, address) { return this.payment(hash, address); }
178
+ }
179
+ //# sourceMappingURL=bitcoin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitcoin.js","sourceRoot":"","sources":["../../swap/bitcoin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,cAAc,EAAE,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1F,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAKxH,MAAM,UAAU,kBAAkB,CAAC,IAAa;IAC5C,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAClC,IAAI,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACzF,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG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AC,SAAS,EAAE,aAAa,EAAE,CAAC;QAC5G,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,KAAK,YAAY,aAAa,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG;gBAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;YAC5G,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAY,EAAE,OAAe,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACvG,KAAK,CAAC,aAAa,CAAC,IAAY,EAAE,OAAe,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CAC7F"}
@@ -0,0 +1,49 @@
1
+ import type { ChainReceipt, FundingEstimate, ProviderQuote, SwapChain, SwapInput, SwapPlan, SwapQuote, SwapStep } from './types.js';
2
+ import type { WalletAccount } from '../network/types.js';
3
+ export declare class BscPayments {
4
+ protected rpc(method: string, params: unknown[]): Promise<unknown>;
5
+ protected assertChain(): Promise<void>;
6
+ blockNumber(): Promise<bigint>;
7
+ private confirmedReceipt;
8
+ receipt(hash: string): Promise<ChainReceipt>;
9
+ payment(hash: string, address: string): Promise<{
10
+ amount: bigint;
11
+ confirmations: number;
12
+ }>;
13
+ }
14
+ export declare class BitcoinPayments {
15
+ payment(hash: string, address: string): Promise<{
16
+ amount: bigint;
17
+ confirmations: number;
18
+ }>;
19
+ blockNumber(): Promise<bigint>;
20
+ protected confirmations(status: Record<string, unknown>): Promise<number>;
21
+ }
22
+ export declare class BscSwapChain extends BscPayments implements SwapChain {
23
+ availableBalance(address: string): Promise<bigint>;
24
+ checkSource(address: string): Promise<{
25
+ balance: bigint;
26
+ nativeBalance: bigint;
27
+ gasPrice: bigint;
28
+ }>;
29
+ allowance(address: string, router: string): Promise<bigint>;
30
+ assertNonceAvailable(address: string): Promise<void>;
31
+ sign(quote: SwapQuote, plan: SwapPlan, kind: SwapStep['kind'], account: WalletAccount): Promise<SwapStep>;
32
+ broadcast(step: SwapStep): Promise<void>;
33
+ estimate(input: SwapInput, offer: ProviderQuote): Promise<FundingEstimate>;
34
+ balance(input: SwapInput, funding: FundingEstimate): Promise<{
35
+ sufficientAsset: boolean;
36
+ sufficientFee: boolean;
37
+ }>;
38
+ checkFunding(quote: SwapQuote, steps: SwapStep[]): Promise<void>;
39
+ assertAvailable(address: string): Promise<void>;
40
+ nextStep(quote: SwapQuote, plan: SwapPlan, steps: SwapStep[]): Promise<SwapStep['kind']>;
41
+ payoutPayment(hash: string, address: string): Promise<{
42
+ amount: bigint;
43
+ confirmations: number;
44
+ }>;
45
+ refundPayment(hash: string, address: string): Promise<{
46
+ amount: bigint;
47
+ confirmations: number;
48
+ }>;
49
+ }
@@ -0,0 +1,255 @@
1
+ import { Web3 } from 'web3';
2
+ import * as bitcoin from 'bitcoinjs-lib';
3
+ import { swapConfig as config } from './config.js';
4
+ import { evmAddress, integer, list, record, swapJson, swapText, textField, transactionHash } from './http.js';
5
+ const web3 = new Web3();
6
+ const approveAbi = {
7
+ name: 'approve', type: 'function',
8
+ inputs: [{ name: 'spender', type: 'address' }, { name: 'amount', type: 'uint256' }]
9
+ };
10
+ const allowanceAbi = {
11
+ name: 'allowance', type: 'function',
12
+ inputs: [{ name: 'owner', type: 'address' }, { name: 'spender', type: 'address' }]
13
+ };
14
+ const transferAbi = {
15
+ name: 'transfer', type: 'function',
16
+ inputs: [{ name: 'to', type: 'address' }, { name: 'amount', type: 'uint256' }]
17
+ };
18
+ const depositAbi = {
19
+ name: 'depositWithExpiry', type: 'function',
20
+ inputs: [
21
+ { name: 'vault', type: 'address' }, { name: 'asset', type: 'address' },
22
+ { name: 'amount', type: 'uint256' }, { name: 'memo', type: 'string' },
23
+ { name: 'expiry', type: 'uint256' }
24
+ ]
25
+ };
26
+ function hex(value) {
27
+ if (typeof value !== 'string' || !/^0x[\da-f]+$/i.test(value))
28
+ throw new Error('Invalid RPC number.');
29
+ return BigInt(value);
30
+ }
31
+ export class BscPayments {
32
+ async rpc(method, params) {
33
+ const response = record(await swapJson(config.source.url, { jsonrpc: '2.0', id: 1, method, params }));
34
+ if (response.error || !('result' in response))
35
+ throw new Error(`BSC RPC ${method} failed.`);
36
+ return response.result;
37
+ }
38
+ async assertChain() {
39
+ if (hex(await this.rpc('eth_chainId', [])) !== BigInt(config.source.chainId)) {
40
+ throw new Error('BSC RPC chain ID mismatch.');
41
+ }
42
+ }
43
+ async blockNumber() { return hex(await this.rpc('eth_blockNumber', [])); }
44
+ async confirmedReceipt(hash) {
45
+ await this.assertChain();
46
+ const value = await this.rpc('eth_getTransactionReceipt', [transactionHash(hash, true)]);
47
+ if (value === null)
48
+ return { receipt: null, confirmations: 0 };
49
+ const receipt = record(value);
50
+ if (transactionHash(receipt.transactionHash, true) !== transactionHash(hash, true))
51
+ throw new Error('Receipt hash mismatch.');
52
+ const block = hex(receipt.blockNumber);
53
+ const [tip, canonical] = await Promise.all([
54
+ this.blockNumber(), this.rpc('eth_getBlockByNumber', [`0x${block.toString(16)}`, false])
55
+ ]);
56
+ if (tip < block || record(canonical).hash !== receipt.blockHash)
57
+ return { receipt: null, confirmations: 0 };
58
+ return { receipt, confirmations: Number(tip - block + 1n) };
59
+ }
60
+ async receipt(hash) {
61
+ const { receipt, confirmations } = await this.confirmedReceipt(hash);
62
+ if (!receipt) {
63
+ const transaction = await this.rpc('eth_getTransactionByHash', [transactionHash(hash, true)]);
64
+ if (transaction === null)
65
+ return { state: 'not_found', confirmations: 0 };
66
+ if (transactionHash(record(transaction).hash, true) !== transactionHash(hash, true))
67
+ throw new Error('Pending transaction hash mismatch.');
68
+ return { state: 'pending', confirmations: 0 };
69
+ }
70
+ if (confirmations < config.bscConfirmations)
71
+ return { state: 'pending', confirmations };
72
+ const status = hex(receipt.status);
73
+ if (status !== 0n && status !== 1n)
74
+ throw new Error('Invalid receipt status.');
75
+ return { state: status === 1n ? 'confirmed' : 'reverted', confirmations };
76
+ }
77
+ async payment(hash, address) {
78
+ const { receipt, confirmations } = await this.confirmedReceipt(hash);
79
+ if (!receipt)
80
+ return { amount: 0n, confirmations: 0 };
81
+ if (hex(receipt.status) !== 1n)
82
+ throw new Error('Refund transaction reverted.');
83
+ const transferTopic = web3.utils.keccak256('Transfer(address,address,uint256)');
84
+ const recipient = `0x${evmAddress(address).slice(2).toLowerCase().padStart(64, '0')}`;
85
+ let amount = 0n;
86
+ for (const value of list(receipt.logs)) {
87
+ const log = record(value);
88
+ if (textField(log.address).toLowerCase() !== config.token.toLowerCase())
89
+ continue;
90
+ const topics = list(log.topics);
91
+ if (topics[0] === transferTopic && typeof topics[2] === 'string' && topics[2].toLowerCase() === recipient) {
92
+ amount += hex(log.data);
93
+ }
94
+ }
95
+ return { amount, confirmations };
96
+ }
97
+ }
98
+ export class BitcoinPayments {
99
+ async payment(hash, address) {
100
+ const id = transactionHash(hash);
101
+ const tx = record(await swapJson(`${config.destination.url}/tx/${id}`));
102
+ if (transactionHash(tx.txid) !== id)
103
+ throw new Error('Bitcoin transaction hash mismatch.');
104
+ const script = bitcoin.address.toOutputScript(address, bitcoin.networks.bitcoin).toString('hex');
105
+ let sats = 0n;
106
+ for (const entry of list(tx.vout)) {
107
+ const output = record(entry);
108
+ if (output.scriptpubkey === script)
109
+ sats += BigInt(integer(output.value));
110
+ }
111
+ return { amount: sats, confirmations: await this.confirmations(record(tx.status)) };
112
+ }
113
+ async blockNumber() {
114
+ const value = (await swapText(`${config.destination.url}/blocks/tip/height`)).trim();
115
+ if (!/^\d+$/.test(value))
116
+ throw new Error('Invalid Bitcoin tip height.');
117
+ return BigInt(value);
118
+ }
119
+ async confirmations(status) {
120
+ if (status.confirmed !== true)
121
+ return 0;
122
+ const height = integer(status.block_height);
123
+ const [tip, canonical] = await Promise.all([
124
+ this.blockNumber(), swapText(`${config.destination.url}/block-height/${height}`)
125
+ ]);
126
+ return canonical.trim() === textField(status.block_hash) ? Math.max(0, Number(tip) - height + 1) : 0;
127
+ }
128
+ }
129
+ export class BscSwapChain extends BscPayments {
130
+ async availableBalance(address) {
131
+ return (await this.checkSource(address)).balance;
132
+ }
133
+ async checkSource(address) {
134
+ evmAddress(address);
135
+ await this.assertChain();
136
+ const [balance, nativeBalance, gasPrice, decimals] = await Promise.all([
137
+ this.rpc('eth_call', [{ to: config.token, data: `0x70a08231${address.slice(2).padStart(64, '0')}` }, 'latest']),
138
+ this.rpc('eth_getBalance', [address, 'latest']),
139
+ this.rpc('eth_gasPrice', []),
140
+ this.rpc('eth_call', [{ to: config.token, data: '0x313ce567' }, 'latest'])
141
+ ]);
142
+ if (hex(decimals) !== BigInt(config.decimals))
143
+ throw new Error('Unexpected BSC USDT decimals.');
144
+ if (hex(gasPrice) <= 0n)
145
+ throw new Error('Invalid BSC gas price.');
146
+ return { balance: hex(balance), nativeBalance: hex(nativeBalance), gasPrice: hex(gasPrice) };
147
+ }
148
+ async allowance(address, router) {
149
+ await this.assertChain();
150
+ const data = web3.eth.abi.encodeFunctionCall(allowanceAbi, [evmAddress(address), evmAddress(router)]);
151
+ return hex(await this.rpc('eth_call', [{ to: config.token, data }, 'latest']));
152
+ }
153
+ async assertNonceAvailable(address) {
154
+ const [latest, pending] = await Promise.all([
155
+ this.rpc('eth_getTransactionCount', [address, 'latest']),
156
+ this.rpc('eth_getTransactionCount', [address, 'pending'])
157
+ ]);
158
+ if (hex(latest) !== hex(pending))
159
+ throw new Error('An outgoing BSC transaction is still pending.');
160
+ }
161
+ async sign(quote, plan, kind, account) {
162
+ await this.assertChain();
163
+ if (web3.eth.accounts.privateKeyToAccount(account.privateKey).address.toLowerCase() !== quote.from.toLowerCase()) {
164
+ throw new Error('Swap signer does not match source account.');
165
+ }
166
+ await this.assertNonceAvailable(quote.from);
167
+ let to = config.token;
168
+ let data;
169
+ let limit = config.gas.approval;
170
+ if (kind !== 'deposit') {
171
+ if (quote.provider !== 'thorchain' || plan.router !== config.thorchain.router)
172
+ throw new Error('Invalid approval router.');
173
+ data = web3.eth.abi.encodeFunctionCall(approveAbi, [plan.router, kind === 'approve' ? quote.amountBaseUnits : '0']);
174
+ }
175
+ else if (quote.provider === 'chainflip') {
176
+ data = web3.eth.abi.encodeFunctionCall(transferAbi, [evmAddress(plan.depositAddress), quote.amountBaseUnits]);
177
+ limit = config.gas.transfer;
178
+ }
179
+ else {
180
+ if (plan.router !== config.thorchain.router || !plan.memo || !plan.expirySeconds)
181
+ throw new Error('Invalid THORChain deposit.');
182
+ to = plan.router;
183
+ data = web3.eth.abi.encodeFunctionCall(depositAbi, [
184
+ evmAddress(plan.depositAddress), config.token, quote.amountBaseUnits, plan.memo, String(plan.expirySeconds)
185
+ ]);
186
+ limit = config.gas.deposit;
187
+ }
188
+ const nonce = hex(await this.rpc('eth_getTransactionCount', [quote.from, 'pending']));
189
+ const gasPrice = BigInt(quote.funding.rate);
190
+ const request = { from: quote.from, to, data, value: '0x0', gasPrice: `0x${gasPrice.toString(16)}` };
191
+ const estimate = hex(await this.rpc('eth_estimateGas', [request]));
192
+ if (estimate > BigInt(limit))
193
+ throw new Error('Gas exceeds the accepted budget; obtain a new quote.');
194
+ const signed = await web3.eth.accounts.signTransaction({
195
+ ...request, nonce, gas: limit, gasPrice, chainId: config.source.chainId, networkId: config.source.chainId, type: '0x0'
196
+ }, account.privateKey);
197
+ if (!signed.rawTransaction)
198
+ throw new Error('Could not sign swap transaction.');
199
+ return {
200
+ kind, nonce: nonce.toString(), rawTransaction: signed.rawTransaction,
201
+ hash: transactionHash(signed.transactionHash, true), confirmed: false, broadcastAttempted: false
202
+ };
203
+ }
204
+ async broadcast(step) {
205
+ await this.assertChain();
206
+ const hash = transactionHash(await this.rpc('eth_sendRawTransaction', [step.rawTransaction]), true);
207
+ if (hash !== step.hash)
208
+ throw new Error('RPC returned an unexpected transaction hash.');
209
+ }
210
+ async estimate(input, offer) {
211
+ const source = await this.checkSource(input.from);
212
+ let gasUnits = config.gas.transfer;
213
+ if (offer.provider === 'thorchain') {
214
+ gasUnits = config.gas.deposit;
215
+ const allowance = await this.allowance(input.from, config.thorchain.router);
216
+ if (allowance < BigInt(input.amountBaseUnits))
217
+ gasUnits += config.gas.approval * (allowance > 0n ? 2 : 1);
218
+ }
219
+ const recommended = offer.provider === 'thorchain' ? BigInt(textField(offer.details.gasPrice)) : 0n;
220
+ const rate = source.gasPrice > recommended ? source.gasPrice : recommended;
221
+ return { asset: 'BNB', decimals: 18, price: 'bnb', rate: rate.toString(), units: gasUnits, budgetBaseUnits: (rate * BigInt(gasUnits)).toString() };
222
+ }
223
+ async balance(input, funding) {
224
+ const source = await this.checkSource(input.from);
225
+ return { sufficientAsset: source.balance >= BigInt(input.amountBaseUnits), sufficientFee: source.nativeBalance >= BigInt(funding.budgetBaseUnits) };
226
+ }
227
+ async checkFunding(quote, steps) {
228
+ const source = await this.checkSource(quote.from);
229
+ if (source.balance < BigInt(quote.amountBaseUnits))
230
+ throw new Error('Insufficient USDT on BSC.');
231
+ const consumed = steps.filter(step => step.confirmed).length * config.gas.approval;
232
+ const remaining = BigInt(quote.funding.units - consumed) * BigInt(quote.funding.rate);
233
+ if (source.nativeBalance < remaining)
234
+ throw new Error('Insufficient BNB for the accepted gas budget.');
235
+ if (source.gasPrice > BigInt(quote.funding.rate))
236
+ throw new Error('BSC gas price increased; obtain a new quote.');
237
+ }
238
+ async assertAvailable(address) { await this.assertNonceAvailable(address); }
239
+ async nextStep(quote, plan, steps) {
240
+ let kind = 'deposit';
241
+ if (plan.router) {
242
+ const allowance = await this.allowance(quote.from, plan.router);
243
+ if (allowance < BigInt(quote.amountBaseUnits))
244
+ kind = allowance > 0n ? 'reset_approval' : 'approve';
245
+ }
246
+ const spent = steps.reduce((sum, step) => sum + (step.kind === 'deposit' ? config.gas.deposit : config.gas.approval), 0);
247
+ const next = kind === 'deposit' ? (quote.provider === 'chainflip' ? config.gas.transfer : config.gas.deposit) : config.gas.approval;
248
+ if (spent + next > quote.funding.units)
249
+ throw new Error('Funding requirements exceed the accepted gas budget.');
250
+ return kind;
251
+ }
252
+ async payoutPayment(hash, address) { return new BitcoinPayments().payment(hash, address); }
253
+ async refundPayment(hash, address) { return this.payment(hash, address); }
254
+ }
255
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../swap/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAI9G,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;AACxB,MAAM,UAAU,GAAG;IACf,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU;IACjC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;CACtF,CAAC;AACF,MAAM,YAAY,GAAG;IACjB,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU;IACnC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;CACrF,CAAC;AACF,MAAM,WAAW,GAAG;IAChB,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU;IAClC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAA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OAAe,IAAI,OAAO,IAAI,eAAe,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3G,KAAK,CAAC,aAAa,CAAC,IAAY,EAAE,OAAe,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CAC7F"}
@@ -0,0 +1,68 @@
1
+ export declare const swapConfig: {
2
+ readonly source: {
3
+ NetworkClass: typeof import("../network/lib/Web3Network.js").default;
4
+ id: string;
5
+ family: "evm";
6
+ chainId: number;
7
+ name: string;
8
+ storageName: string;
9
+ url: string;
10
+ nativeToken: string;
11
+ explorer: string;
12
+ tokens: {
13
+ USDT: {
14
+ address: string;
15
+ };
16
+ };
17
+ };
18
+ readonly destination: {
19
+ NetworkClass: typeof import("../network/lib/BitcoinNetwork.js").default;
20
+ id: string;
21
+ family: "bitcoin";
22
+ name: string;
23
+ url: string;
24
+ nativeToken: string;
25
+ feeRate: number;
26
+ explorer: string;
27
+ tokens: {};
28
+ };
29
+ readonly asset: "USDT";
30
+ readonly token: string;
31
+ readonly decimals: 18;
32
+ readonly slippageBps: 50;
33
+ readonly bitcoinConfirmations: 3;
34
+ readonly bscConfirmations: 15;
35
+ readonly httpTimeoutMs: 15000;
36
+ readonly pollIntervalMs: 10000;
37
+ readonly quoteLifetimeMs: 300000;
38
+ readonly referenceMaxAgeMs: 300000;
39
+ readonly clockSkewMs: 60000;
40
+ readonly fundingMarginMs: 30000;
41
+ readonly attentionAfterMs: 3600000;
42
+ readonly bitcoin: {
43
+ readonly changeDustSats: 546;
44
+ readonly memoDustSats: 294;
45
+ readonly maxOutputs: 10;
46
+ readonly feeTargetBlocks: 1;
47
+ };
48
+ readonly gas: {
49
+ readonly approval: 100000;
50
+ readonly transfer: 120000;
51
+ readonly deposit: 350000;
52
+ };
53
+ readonly chainflip: {
54
+ readonly url: "https://chainflip-swap.chainflip.io";
55
+ readonly blockSeconds: 6;
56
+ readonly refundRetryBlocks: 100;
57
+ readonly sourceAsset: "BscUsdt";
58
+ };
59
+ readonly thorchain: {
60
+ readonly midgardUrl: "https://gateway.liquify.com/chain/thorchain_midgard";
61
+ readonly streamingInterval: 1;
62
+ readonly streamingQuantity: 0;
63
+ readonly url: "https://gateway.liquify.com/chain/thorchain_api";
64
+ readonly router: "0xb30ec53f98ff5947ede720d32ac2da7e52a5f56b";
65
+ readonly asset: `BSC.USDT-${string}`;
66
+ };
67
+ readonly pricesUrl: "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,binancecoin,tether&vs_currencies=usd&include_last_updated_at=true&precision=8";
68
+ };