@chainflip/bitcoin 1.2.6 → 1.2.7

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/dist/index.cjs CHANGED
@@ -215,7 +215,7 @@ var addressByteLengths = {
215
215
  Polkadot: 32,
216
216
  Assethub: 32
217
217
  };
218
- var createSwapDataCodec = (asset) => scaleTs.Struct({
218
+ var createSwapDataCodecV0 = (asset) => scaleTs.Struct({
219
219
  version: scaleTs.u8,
220
220
  destinationAsset: scaleTs.u8,
221
221
  destinationAddress: scaleTs.Bytes(addressByteLengths[chainflip.assetConstants[asset].chain]),
@@ -229,6 +229,21 @@ var createSwapDataCodec = (asset) => scaleTs.Struct({
229
229
  affiliates: scaleTs.Vector(scaleTs.Struct({ accountIndex: scaleTs.u8, commissionBps: scaleTs.u8 }))
230
230
  })
231
231
  });
232
+ var createSwapDataCodecV1 = (asset) => scaleTs.Struct({
233
+ version: scaleTs.u8,
234
+ destinationAsset: scaleTs.u8,
235
+ destinationAddress: scaleTs.Bytes(addressByteLengths[chainflip.assetConstants[asset].chain]),
236
+ parameters: scaleTs.Struct({
237
+ retryDuration: scaleTs.u16,
238
+ minOutputAmount: scaleTs.u128,
239
+ maxOraclePriceSlippage: scaleTs.u8,
240
+ numberOfChunks: scaleTs.u16,
241
+ chunkInterval: scaleTs.u16,
242
+ boostFee: scaleTs.u8,
243
+ brokerFee: scaleTs.u8,
244
+ affiliates: scaleTs.Vector(scaleTs.Struct({ accountIndex: scaleTs.u8, commissionBps: scaleTs.u8 }))
245
+ })
246
+ });
232
247
 
233
248
  // src/deposit.ts
234
249
  var encodeChainAddress = (data, asset) => {
@@ -250,11 +265,18 @@ var contractIdToInternalAsset = Object.fromEntries(
250
265
  );
251
266
  var parseVaultSwapData = (data) => {
252
267
  const version = data[0];
253
- assertion.assert(version === 0, "unsupported version");
254
268
  const contractId = data[1];
255
269
  const outputAsset = contractIdToInternalAsset[contractId];
270
+ let destinationAddress;
271
+ let parameters;
272
+ if (version === 1) {
273
+ ({ destinationAddress, parameters } = createSwapDataCodecV1(outputAsset).dec(data));
274
+ } else if (version === 0) {
275
+ ({ destinationAddress, parameters } = createSwapDataCodecV0(outputAsset).dec(data));
276
+ } else {
277
+ throw new Error("unsupported version");
278
+ }
256
279
  assertion.assert(outputAsset, "unknown asset contract id");
257
- const { destinationAddress, parameters } = createSwapDataCodec(outputAsset).dec(data);
258
280
  return {
259
281
  ...parameters,
260
282
  outputAsset,
@@ -277,7 +299,8 @@ var findVaultSwapData = async (url, txId) => {
277
299
  refundParams: {
278
300
  refundAddress: tx.vout[2].scriptPubKey.address,
279
301
  retryDuration: data.retryDuration,
280
- minPrice: getX128PriceFromAmounts(amount, data.minOutputAmount)
302
+ minPrice: getX128PriceFromAmounts(amount, data.minOutputAmount),
303
+ maxOraclePriceSlippage: "maxOraclePriceSlippage" in data ? data.maxOraclePriceSlippage : null
281
304
  },
282
305
  destinationAddress: data.destinationAddress,
283
306
  outputAsset: data.outputAsset,
package/dist/index.js CHANGED
@@ -188,7 +188,7 @@ var addressByteLengths = {
188
188
  Polkadot: 32,
189
189
  Assethub: 32
190
190
  };
191
- var createSwapDataCodec = (asset) => Struct({
191
+ var createSwapDataCodecV0 = (asset) => Struct({
192
192
  version: u8,
193
193
  destinationAsset: u8,
194
194
  destinationAddress: Bytes(addressByteLengths[assetConstants[asset].chain]),
@@ -202,6 +202,21 @@ var createSwapDataCodec = (asset) => Struct({
202
202
  affiliates: Vector(Struct({ accountIndex: u8, commissionBps: u8 }))
203
203
  })
204
204
  });
205
+ var createSwapDataCodecV1 = (asset) => Struct({
206
+ version: u8,
207
+ destinationAsset: u8,
208
+ destinationAddress: Bytes(addressByteLengths[assetConstants[asset].chain]),
209
+ parameters: Struct({
210
+ retryDuration: u16,
211
+ minOutputAmount: u128,
212
+ maxOraclePriceSlippage: u8,
213
+ numberOfChunks: u16,
214
+ chunkInterval: u16,
215
+ boostFee: u8,
216
+ brokerFee: u8,
217
+ affiliates: Vector(Struct({ accountIndex: u8, commissionBps: u8 }))
218
+ })
219
+ });
205
220
 
206
221
  // src/deposit.ts
207
222
  var encodeChainAddress = (data, asset) => {
@@ -223,11 +238,18 @@ var contractIdToInternalAsset = Object.fromEntries(
223
238
  );
224
239
  var parseVaultSwapData = (data) => {
225
240
  const version = data[0];
226
- assert(version === 0, "unsupported version");
227
241
  const contractId = data[1];
228
242
  const outputAsset = contractIdToInternalAsset[contractId];
243
+ let destinationAddress;
244
+ let parameters;
245
+ if (version === 1) {
246
+ ({ destinationAddress, parameters } = createSwapDataCodecV1(outputAsset).dec(data));
247
+ } else if (version === 0) {
248
+ ({ destinationAddress, parameters } = createSwapDataCodecV0(outputAsset).dec(data));
249
+ } else {
250
+ throw new Error("unsupported version");
251
+ }
229
252
  assert(outputAsset, "unknown asset contract id");
230
- const { destinationAddress, parameters } = createSwapDataCodec(outputAsset).dec(data);
231
253
  return {
232
254
  ...parameters,
233
255
  outputAsset,
@@ -250,7 +272,8 @@ var findVaultSwapData = async (url, txId) => {
250
272
  refundParams: {
251
273
  refundAddress: tx.vout[2].scriptPubKey.address,
252
274
  retryDuration: data.retryDuration,
253
- minPrice: getX128PriceFromAmounts(amount, data.minOutputAmount)
275
+ minPrice: getX128PriceFromAmounts(amount, data.minOutputAmount),
276
+ maxOraclePriceSlippage: "maxOraclePriceSlippage" in data ? data.maxOraclePriceSlippage : null
254
277
  },
255
278
  destinationAddress: data.destinationAddress,
256
279
  outputAsset: data.outputAsset,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/bitcoin",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/chainflip-io/chainflip-product-toolkit.git",
6
6
  "publishConfig": {
@@ -24,11 +24,11 @@
24
24
  }
25
25
  },
26
26
  "dependencies": {
27
- "@chainflip/utils": "0.8.6",
28
- "bignumber.js": "^9.3.0",
27
+ "@chainflip/utils": "0.8.18",
28
+ "bignumber.js": "^9.3.1",
29
29
  "bitcoinjs-lib": "7.0.0-rc.0",
30
30
  "scale-ts": "^1.6.1",
31
- "zod": "^3.25.67"
31
+ "zod": "^3.25.75"
32
32
  },
33
33
  "scripts": {
34
34
  "eslint:check": "pnpm eslint --max-warnings 0 './**/*.ts'",