@percolatorct/sdk 2.0.5 → 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.
package/dist/index.js CHANGED
@@ -272,10 +272,17 @@ function encodeFeedId(feedId) {
272
272
  }
273
273
  var INIT_MARKET_BASE_LEN = 304;
274
274
  var INIT_MARKET_EXTENDED_TAIL_LEN = 66;
275
- function extendedTailHasNonZero(t) {
276
- const toBigInt = (v) => typeof v === "string" ? BigInt(v) : v;
277
- return t.insuranceWithdrawMaxBps !== 0 || toBigInt(t.insuranceWithdrawCooldownSlots) !== 0n || toBigInt(t.permissionlessResolveStaleSlots) !== 0n || toBigInt(t.fundingHorizonSlots) !== 0n || toBigInt(t.fundingKBps) !== 0n || toBigInt(t.fundingMaxPremiumBps) !== 0n || toBigInt(t.fundingMaxBpsPerSlot) !== 0n || toBigInt(t.markMinFee) !== 0n || toBigInt(t.forceCloseDelaySlots) !== 0n;
278
- }
275
+ var DEFAULT_EXTENDED_TAIL = {
276
+ insuranceWithdrawMaxBps: 0,
277
+ insuranceWithdrawCooldownSlots: 0n,
278
+ permissionlessResolveStaleSlots: 0n,
279
+ fundingHorizonSlots: 500n,
280
+ fundingKBps: 100n,
281
+ fundingMaxPremiumBps: 500n,
282
+ fundingMaxBpsPerSlot: 1000n,
283
+ markMinFee: 0n,
284
+ forceCloseDelaySlots: 1n
285
+ };
279
286
  function encodeExtendedTail(t) {
280
287
  return concatBytes(
281
288
  encU16(t.insuranceWithdrawMaxBps),
@@ -329,16 +336,13 @@ function encodeInitMarket(args) {
329
336
  `encodeInitMarket: base payload expected ${INIT_MARKET_BASE_LEN} bytes, got ${base.length}`
330
337
  );
331
338
  }
332
- if (args.extendedTail && extendedTailHasNonZero(args.extendedTail)) {
333
- const tail = encodeExtendedTail(args.extendedTail);
334
- if (tail.length !== INIT_MARKET_EXTENDED_TAIL_LEN) {
335
- throw new Error(
336
- `encodeInitMarket: extended tail expected ${INIT_MARKET_EXTENDED_TAIL_LEN} bytes, got ${tail.length}`
337
- );
338
- }
339
- return concatBytes(base, tail);
339
+ const tail = encodeExtendedTail(args.extendedTail ?? DEFAULT_EXTENDED_TAIL);
340
+ if (tail.length !== INIT_MARKET_EXTENDED_TAIL_LEN) {
341
+ throw new Error(
342
+ `encodeInitMarket: extended tail expected ${INIT_MARKET_EXTENDED_TAIL_LEN} bytes, got ${tail.length}`
343
+ );
340
344
  }
341
- return base;
345
+ return concatBytes(base, tail);
342
346
  }
343
347
  function encodeInitUser(args) {
344
348
  return concatBytes(encU8(IX_TAG.InitUser), encU64(args.feePayment));