@0dotxyz/p0-ts-sdk 2.2.0-beta.1 → 2.2.0-beta.3

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
@@ -12,6 +12,7 @@ var buffer = require('buffer');
12
12
  var borsh$1 = require('borsh');
13
13
  var borsh = require('@coral-xyz/borsh');
14
14
  var WebSocket = require('ws');
15
+ var msgpack = require('@msgpack/msgpack');
15
16
  var api = require('@jup-ag/api');
16
17
  var onDemand = require('@switchboard-xyz/on-demand');
17
18
  var common = require('@switchboard-xyz/common');
@@ -385,7 +386,6 @@ var MAX_U64 = BigInt("18446744073709551615").toString();
385
386
 
386
387
  // src/constants/transaction.consts.ts
387
388
  var MAX_TX_SIZE = 1232;
388
- var MAX_WRITABLE_ACCOUNTS = 64;
389
389
  var MAX_ACCOUNT_LOCKS = 64;
390
390
  var BUNDLE_TX_SIZE = 81;
391
391
  var PRIORITY_TX_SIZE = 44;
@@ -44101,1438 +44101,6 @@ function makeUpdateJupLendRate({ lendingState }) {
44101
44101
  lendingState.rewardsRateModel
44102
44102
  );
44103
44103
  }
44104
-
44105
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/utf8.mjs
44106
- function utf8Count(str) {
44107
- const strLength = str.length;
44108
- let byteLength = 0;
44109
- let pos = 0;
44110
- while (pos < strLength) {
44111
- let value = str.charCodeAt(pos++);
44112
- if ((value & 4294967168) === 0) {
44113
- byteLength++;
44114
- continue;
44115
- } else if ((value & 4294965248) === 0) {
44116
- byteLength += 2;
44117
- } else {
44118
- if (value >= 55296 && value <= 56319) {
44119
- if (pos < strLength) {
44120
- const extra = str.charCodeAt(pos);
44121
- if ((extra & 64512) === 56320) {
44122
- ++pos;
44123
- value = ((value & 1023) << 10) + (extra & 1023) + 65536;
44124
- }
44125
- }
44126
- }
44127
- if ((value & 4294901760) === 0) {
44128
- byteLength += 3;
44129
- } else {
44130
- byteLength += 4;
44131
- }
44132
- }
44133
- }
44134
- return byteLength;
44135
- }
44136
- function utf8EncodeJs(str, output, outputOffset) {
44137
- const strLength = str.length;
44138
- let offset = outputOffset;
44139
- let pos = 0;
44140
- while (pos < strLength) {
44141
- let value = str.charCodeAt(pos++);
44142
- if ((value & 4294967168) === 0) {
44143
- output[offset++] = value;
44144
- continue;
44145
- } else if ((value & 4294965248) === 0) {
44146
- output[offset++] = value >> 6 & 31 | 192;
44147
- } else {
44148
- if (value >= 55296 && value <= 56319) {
44149
- if (pos < strLength) {
44150
- const extra = str.charCodeAt(pos);
44151
- if ((extra & 64512) === 56320) {
44152
- ++pos;
44153
- value = ((value & 1023) << 10) + (extra & 1023) + 65536;
44154
- }
44155
- }
44156
- }
44157
- if ((value & 4294901760) === 0) {
44158
- output[offset++] = value >> 12 & 15 | 224;
44159
- output[offset++] = value >> 6 & 63 | 128;
44160
- } else {
44161
- output[offset++] = value >> 18 & 7 | 240;
44162
- output[offset++] = value >> 12 & 63 | 128;
44163
- output[offset++] = value >> 6 & 63 | 128;
44164
- }
44165
- }
44166
- output[offset++] = value & 63 | 128;
44167
- }
44168
- }
44169
- var sharedTextEncoder = new TextEncoder();
44170
- var TEXT_ENCODER_THRESHOLD = 50;
44171
- function utf8EncodeTE(str, output, outputOffset) {
44172
- sharedTextEncoder.encodeInto(str, output.subarray(outputOffset));
44173
- }
44174
- function utf8Encode(str, output, outputOffset) {
44175
- if (str.length > TEXT_ENCODER_THRESHOLD) {
44176
- utf8EncodeTE(str, output, outputOffset);
44177
- } else {
44178
- utf8EncodeJs(str, output, outputOffset);
44179
- }
44180
- }
44181
- var CHUNK_SIZE = 4096;
44182
- function utf8DecodeJs(bytes, inputOffset, byteLength) {
44183
- let offset = inputOffset;
44184
- const end = offset + byteLength;
44185
- const units = [];
44186
- let result = "";
44187
- while (offset < end) {
44188
- const byte1 = bytes[offset++];
44189
- if ((byte1 & 128) === 0) {
44190
- units.push(byte1);
44191
- } else if ((byte1 & 224) === 192) {
44192
- const byte2 = bytes[offset++] & 63;
44193
- units.push((byte1 & 31) << 6 | byte2);
44194
- } else if ((byte1 & 240) === 224) {
44195
- const byte2 = bytes[offset++] & 63;
44196
- const byte3 = bytes[offset++] & 63;
44197
- units.push((byte1 & 31) << 12 | byte2 << 6 | byte3);
44198
- } else if ((byte1 & 248) === 240) {
44199
- const byte2 = bytes[offset++] & 63;
44200
- const byte3 = bytes[offset++] & 63;
44201
- const byte4 = bytes[offset++] & 63;
44202
- let unit = (byte1 & 7) << 18 | byte2 << 12 | byte3 << 6 | byte4;
44203
- if (unit > 65535) {
44204
- unit -= 65536;
44205
- units.push(unit >>> 10 & 1023 | 55296);
44206
- unit = 56320 | unit & 1023;
44207
- }
44208
- units.push(unit);
44209
- } else {
44210
- units.push(byte1);
44211
- }
44212
- if (units.length >= CHUNK_SIZE) {
44213
- result += String.fromCharCode(...units);
44214
- units.length = 0;
44215
- }
44216
- }
44217
- if (units.length > 0) {
44218
- result += String.fromCharCode(...units);
44219
- }
44220
- return result;
44221
- }
44222
- var sharedTextDecoder = new TextDecoder();
44223
- var TEXT_DECODER_THRESHOLD = 200;
44224
- function utf8DecodeTD(bytes, inputOffset, byteLength) {
44225
- const stringBytes = bytes.subarray(inputOffset, inputOffset + byteLength);
44226
- return sharedTextDecoder.decode(stringBytes);
44227
- }
44228
- function utf8Decode(bytes, inputOffset, byteLength) {
44229
- if (byteLength > TEXT_DECODER_THRESHOLD) {
44230
- return utf8DecodeTD(bytes, inputOffset, byteLength);
44231
- } else {
44232
- return utf8DecodeJs(bytes, inputOffset, byteLength);
44233
- }
44234
- }
44235
-
44236
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/ExtData.mjs
44237
- var ExtData = class {
44238
- type;
44239
- data;
44240
- constructor(type, data) {
44241
- this.type = type;
44242
- this.data = data;
44243
- }
44244
- };
44245
-
44246
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/DecodeError.mjs
44247
- var DecodeError = class _DecodeError extends Error {
44248
- constructor(message) {
44249
- super(message);
44250
- const proto = Object.create(_DecodeError.prototype);
44251
- Object.setPrototypeOf(this, proto);
44252
- Object.defineProperty(this, "name", {
44253
- configurable: true,
44254
- enumerable: false,
44255
- value: _DecodeError.name
44256
- });
44257
- }
44258
- };
44259
-
44260
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/int.mjs
44261
- var UINT32_MAX = 4294967295;
44262
- function setUint64(view, offset, value) {
44263
- const high = value / 4294967296;
44264
- const low = value;
44265
- view.setUint32(offset, high);
44266
- view.setUint32(offset + 4, low);
44267
- }
44268
- function setInt64(view, offset, value) {
44269
- const high = Math.floor(value / 4294967296);
44270
- const low = value;
44271
- view.setUint32(offset, high);
44272
- view.setUint32(offset + 4, low);
44273
- }
44274
- function getInt64(view, offset) {
44275
- const high = view.getInt32(offset);
44276
- const low = view.getUint32(offset + 4);
44277
- return high * 4294967296 + low;
44278
- }
44279
- function getUint64(view, offset) {
44280
- const high = view.getUint32(offset);
44281
- const low = view.getUint32(offset + 4);
44282
- return high * 4294967296 + low;
44283
- }
44284
-
44285
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/timestamp.mjs
44286
- var EXT_TIMESTAMP = -1;
44287
- var TIMESTAMP32_MAX_SEC = 4294967296 - 1;
44288
- var TIMESTAMP64_MAX_SEC = 17179869184 - 1;
44289
- function encodeTimeSpecToTimestamp({ sec, nsec }) {
44290
- if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) {
44291
- if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {
44292
- const rv = new Uint8Array(4);
44293
- const view = new DataView(rv.buffer);
44294
- view.setUint32(0, sec);
44295
- return rv;
44296
- } else {
44297
- const secHigh = sec / 4294967296;
44298
- const secLow = sec & 4294967295;
44299
- const rv = new Uint8Array(8);
44300
- const view = new DataView(rv.buffer);
44301
- view.setUint32(0, nsec << 2 | secHigh & 3);
44302
- view.setUint32(4, secLow);
44303
- return rv;
44304
- }
44305
- } else {
44306
- const rv = new Uint8Array(12);
44307
- const view = new DataView(rv.buffer);
44308
- view.setUint32(0, nsec);
44309
- setInt64(view, 4, sec);
44310
- return rv;
44311
- }
44312
- }
44313
- function encodeDateToTimeSpec(date) {
44314
- const msec = date.getTime();
44315
- const sec = Math.floor(msec / 1e3);
44316
- const nsec = (msec - sec * 1e3) * 1e6;
44317
- const nsecInSec = Math.floor(nsec / 1e9);
44318
- return {
44319
- sec: sec + nsecInSec,
44320
- nsec: nsec - nsecInSec * 1e9
44321
- };
44322
- }
44323
- function encodeTimestampExtension(object2) {
44324
- if (object2 instanceof Date) {
44325
- const timeSpec = encodeDateToTimeSpec(object2);
44326
- return encodeTimeSpecToTimestamp(timeSpec);
44327
- } else {
44328
- return null;
44329
- }
44330
- }
44331
- function decodeTimestampToTimeSpec(data) {
44332
- const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
44333
- switch (data.byteLength) {
44334
- case 4: {
44335
- const sec = view.getUint32(0);
44336
- const nsec = 0;
44337
- return { sec, nsec };
44338
- }
44339
- case 8: {
44340
- const nsec30AndSecHigh2 = view.getUint32(0);
44341
- const secLow32 = view.getUint32(4);
44342
- const sec = (nsec30AndSecHigh2 & 3) * 4294967296 + secLow32;
44343
- const nsec = nsec30AndSecHigh2 >>> 2;
44344
- return { sec, nsec };
44345
- }
44346
- case 12: {
44347
- const sec = getInt64(view, 4);
44348
- const nsec = view.getUint32(0);
44349
- return { sec, nsec };
44350
- }
44351
- default:
44352
- throw new DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${data.length}`);
44353
- }
44354
- }
44355
- function decodeTimestampExtension(data) {
44356
- const timeSpec = decodeTimestampToTimeSpec(data);
44357
- return new Date(timeSpec.sec * 1e3 + timeSpec.nsec / 1e6);
44358
- }
44359
- var timestampExtension = {
44360
- type: EXT_TIMESTAMP,
44361
- encode: encodeTimestampExtension,
44362
- decode: decodeTimestampExtension
44363
- };
44364
-
44365
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/ExtensionCodec.mjs
44366
- var ExtensionCodec = class _ExtensionCodec {
44367
- static defaultCodec = new _ExtensionCodec();
44368
- // ensures ExtensionCodecType<X> matches ExtensionCodec<X>
44369
- // this will make type errors a lot more clear
44370
- // eslint-disable-next-line @typescript-eslint/naming-convention
44371
- __brand;
44372
- // built-in extensions
44373
- builtInEncoders = [];
44374
- builtInDecoders = [];
44375
- // custom extensions
44376
- encoders = [];
44377
- decoders = [];
44378
- constructor() {
44379
- this.register(timestampExtension);
44380
- }
44381
- register({ type, encode, decode }) {
44382
- if (type >= 0) {
44383
- this.encoders[type] = encode;
44384
- this.decoders[type] = decode;
44385
- } else {
44386
- const index = -1 - type;
44387
- this.builtInEncoders[index] = encode;
44388
- this.builtInDecoders[index] = decode;
44389
- }
44390
- }
44391
- tryToEncode(object2, context) {
44392
- for (let i = 0; i < this.builtInEncoders.length; i++) {
44393
- const encodeExt = this.builtInEncoders[i];
44394
- if (encodeExt != null) {
44395
- const data = encodeExt(object2, context);
44396
- if (data != null) {
44397
- const type = -1 - i;
44398
- return new ExtData(type, data);
44399
- }
44400
- }
44401
- }
44402
- for (let i = 0; i < this.encoders.length; i++) {
44403
- const encodeExt = this.encoders[i];
44404
- if (encodeExt != null) {
44405
- const data = encodeExt(object2, context);
44406
- if (data != null) {
44407
- const type = i;
44408
- return new ExtData(type, data);
44409
- }
44410
- }
44411
- }
44412
- if (object2 instanceof ExtData) {
44413
- return object2;
44414
- }
44415
- return null;
44416
- }
44417
- decode(data, type, context) {
44418
- const decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];
44419
- if (decodeExt) {
44420
- return decodeExt(data, type, context);
44421
- } else {
44422
- return new ExtData(type, data);
44423
- }
44424
- }
44425
- };
44426
-
44427
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/typedArrays.mjs
44428
- function isArrayBufferLike(buffer) {
44429
- return buffer instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && buffer instanceof SharedArrayBuffer;
44430
- }
44431
- function ensureUint8Array(buffer) {
44432
- if (buffer instanceof Uint8Array) {
44433
- return buffer;
44434
- } else if (ArrayBuffer.isView(buffer)) {
44435
- return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
44436
- } else if (isArrayBufferLike(buffer)) {
44437
- return new Uint8Array(buffer);
44438
- } else {
44439
- return Uint8Array.from(buffer);
44440
- }
44441
- }
44442
-
44443
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/Encoder.mjs
44444
- var DEFAULT_MAX_DEPTH = 100;
44445
- var DEFAULT_INITIAL_BUFFER_SIZE = 2048;
44446
- var Encoder = class _Encoder {
44447
- extensionCodec;
44448
- context;
44449
- useBigInt64;
44450
- maxDepth;
44451
- initialBufferSize;
44452
- sortKeys;
44453
- forceFloat32;
44454
- ignoreUndefined;
44455
- forceIntegerToFloat;
44456
- pos;
44457
- view;
44458
- bytes;
44459
- entered = false;
44460
- constructor(options) {
44461
- this.extensionCodec = options?.extensionCodec ?? ExtensionCodec.defaultCodec;
44462
- this.context = options?.context;
44463
- this.useBigInt64 = options?.useBigInt64 ?? false;
44464
- this.maxDepth = options?.maxDepth ?? DEFAULT_MAX_DEPTH;
44465
- this.initialBufferSize = options?.initialBufferSize ?? DEFAULT_INITIAL_BUFFER_SIZE;
44466
- this.sortKeys = options?.sortKeys ?? false;
44467
- this.forceFloat32 = options?.forceFloat32 ?? false;
44468
- this.ignoreUndefined = options?.ignoreUndefined ?? false;
44469
- this.forceIntegerToFloat = options?.forceIntegerToFloat ?? false;
44470
- this.pos = 0;
44471
- this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
44472
- this.bytes = new Uint8Array(this.view.buffer);
44473
- }
44474
- clone() {
44475
- return new _Encoder({
44476
- extensionCodec: this.extensionCodec,
44477
- context: this.context,
44478
- useBigInt64: this.useBigInt64,
44479
- maxDepth: this.maxDepth,
44480
- initialBufferSize: this.initialBufferSize,
44481
- sortKeys: this.sortKeys,
44482
- forceFloat32: this.forceFloat32,
44483
- ignoreUndefined: this.ignoreUndefined,
44484
- forceIntegerToFloat: this.forceIntegerToFloat
44485
- });
44486
- }
44487
- reinitializeState() {
44488
- this.pos = 0;
44489
- }
44490
- /**
44491
- * This is almost equivalent to {@link Encoder#encode}, but it returns an reference of the encoder's internal buffer and thus much faster than {@link Encoder#encode}.
44492
- *
44493
- * @returns Encodes the object and returns a shared reference the encoder's internal buffer.
44494
- */
44495
- encodeSharedRef(object2) {
44496
- if (this.entered) {
44497
- const instance = this.clone();
44498
- return instance.encodeSharedRef(object2);
44499
- }
44500
- try {
44501
- this.entered = true;
44502
- this.reinitializeState();
44503
- this.doEncode(object2, 1);
44504
- return this.bytes.subarray(0, this.pos);
44505
- } finally {
44506
- this.entered = false;
44507
- }
44508
- }
44509
- /**
44510
- * @returns Encodes the object and returns a copy of the encoder's internal buffer.
44511
- */
44512
- encode(object2) {
44513
- if (this.entered) {
44514
- const instance = this.clone();
44515
- return instance.encode(object2);
44516
- }
44517
- try {
44518
- this.entered = true;
44519
- this.reinitializeState();
44520
- this.doEncode(object2, 1);
44521
- return this.bytes.slice(0, this.pos);
44522
- } finally {
44523
- this.entered = false;
44524
- }
44525
- }
44526
- doEncode(object2, depth) {
44527
- if (depth > this.maxDepth) {
44528
- throw new Error(`Too deep objects in depth ${depth}`);
44529
- }
44530
- if (object2 == null) {
44531
- this.encodeNil();
44532
- } else if (typeof object2 === "boolean") {
44533
- this.encodeBoolean(object2);
44534
- } else if (typeof object2 === "number") {
44535
- if (!this.forceIntegerToFloat) {
44536
- this.encodeNumber(object2);
44537
- } else {
44538
- this.encodeNumberAsFloat(object2);
44539
- }
44540
- } else if (typeof object2 === "string") {
44541
- this.encodeString(object2);
44542
- } else if (this.useBigInt64 && typeof object2 === "bigint") {
44543
- this.encodeBigInt64(object2);
44544
- } else {
44545
- this.encodeObject(object2, depth);
44546
- }
44547
- }
44548
- ensureBufferSizeToWrite(sizeToWrite) {
44549
- const requiredSize = this.pos + sizeToWrite;
44550
- if (this.view.byteLength < requiredSize) {
44551
- this.resizeBuffer(requiredSize * 2);
44552
- }
44553
- }
44554
- resizeBuffer(newSize) {
44555
- const newBuffer = new ArrayBuffer(newSize);
44556
- const newBytes = new Uint8Array(newBuffer);
44557
- const newView = new DataView(newBuffer);
44558
- newBytes.set(this.bytes);
44559
- this.view = newView;
44560
- this.bytes = newBytes;
44561
- }
44562
- encodeNil() {
44563
- this.writeU8(192);
44564
- }
44565
- encodeBoolean(object2) {
44566
- if (object2 === false) {
44567
- this.writeU8(194);
44568
- } else {
44569
- this.writeU8(195);
44570
- }
44571
- }
44572
- encodeNumber(object2) {
44573
- if (!this.forceIntegerToFloat && Number.isSafeInteger(object2)) {
44574
- if (object2 >= 0) {
44575
- if (object2 < 128) {
44576
- this.writeU8(object2);
44577
- } else if (object2 < 256) {
44578
- this.writeU8(204);
44579
- this.writeU8(object2);
44580
- } else if (object2 < 65536) {
44581
- this.writeU8(205);
44582
- this.writeU16(object2);
44583
- } else if (object2 < 4294967296) {
44584
- this.writeU8(206);
44585
- this.writeU32(object2);
44586
- } else if (!this.useBigInt64) {
44587
- this.writeU8(207);
44588
- this.writeU64(object2);
44589
- } else {
44590
- this.encodeNumberAsFloat(object2);
44591
- }
44592
- } else {
44593
- if (object2 >= -32) {
44594
- this.writeU8(224 | object2 + 32);
44595
- } else if (object2 >= -128) {
44596
- this.writeU8(208);
44597
- this.writeI8(object2);
44598
- } else if (object2 >= -32768) {
44599
- this.writeU8(209);
44600
- this.writeI16(object2);
44601
- } else if (object2 >= -2147483648) {
44602
- this.writeU8(210);
44603
- this.writeI32(object2);
44604
- } else if (!this.useBigInt64) {
44605
- this.writeU8(211);
44606
- this.writeI64(object2);
44607
- } else {
44608
- this.encodeNumberAsFloat(object2);
44609
- }
44610
- }
44611
- } else {
44612
- this.encodeNumberAsFloat(object2);
44613
- }
44614
- }
44615
- encodeNumberAsFloat(object2) {
44616
- if (this.forceFloat32) {
44617
- this.writeU8(202);
44618
- this.writeF32(object2);
44619
- } else {
44620
- this.writeU8(203);
44621
- this.writeF64(object2);
44622
- }
44623
- }
44624
- encodeBigInt64(object2) {
44625
- if (object2 >= BigInt(0)) {
44626
- this.writeU8(207);
44627
- this.writeBigUint64(object2);
44628
- } else {
44629
- this.writeU8(211);
44630
- this.writeBigInt64(object2);
44631
- }
44632
- }
44633
- writeStringHeader(byteLength) {
44634
- if (byteLength < 32) {
44635
- this.writeU8(160 + byteLength);
44636
- } else if (byteLength < 256) {
44637
- this.writeU8(217);
44638
- this.writeU8(byteLength);
44639
- } else if (byteLength < 65536) {
44640
- this.writeU8(218);
44641
- this.writeU16(byteLength);
44642
- } else if (byteLength < 4294967296) {
44643
- this.writeU8(219);
44644
- this.writeU32(byteLength);
44645
- } else {
44646
- throw new Error(`Too long string: ${byteLength} bytes in UTF-8`);
44647
- }
44648
- }
44649
- encodeString(object2) {
44650
- const maxHeaderSize = 1 + 4;
44651
- const byteLength = utf8Count(object2);
44652
- this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
44653
- this.writeStringHeader(byteLength);
44654
- utf8Encode(object2, this.bytes, this.pos);
44655
- this.pos += byteLength;
44656
- }
44657
- encodeObject(object2, depth) {
44658
- const ext = this.extensionCodec.tryToEncode(object2, this.context);
44659
- if (ext != null) {
44660
- this.encodeExtension(ext);
44661
- } else if (Array.isArray(object2)) {
44662
- this.encodeArray(object2, depth);
44663
- } else if (ArrayBuffer.isView(object2)) {
44664
- this.encodeBinary(object2);
44665
- } else if (typeof object2 === "object") {
44666
- this.encodeMap(object2, depth);
44667
- } else {
44668
- throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(object2)}`);
44669
- }
44670
- }
44671
- encodeBinary(object2) {
44672
- const size = object2.byteLength;
44673
- if (size < 256) {
44674
- this.writeU8(196);
44675
- this.writeU8(size);
44676
- } else if (size < 65536) {
44677
- this.writeU8(197);
44678
- this.writeU16(size);
44679
- } else if (size < 4294967296) {
44680
- this.writeU8(198);
44681
- this.writeU32(size);
44682
- } else {
44683
- throw new Error(`Too large binary: ${size}`);
44684
- }
44685
- const bytes = ensureUint8Array(object2);
44686
- this.writeU8a(bytes);
44687
- }
44688
- encodeArray(object2, depth) {
44689
- const size = object2.length;
44690
- if (size < 16) {
44691
- this.writeU8(144 + size);
44692
- } else if (size < 65536) {
44693
- this.writeU8(220);
44694
- this.writeU16(size);
44695
- } else if (size < 4294967296) {
44696
- this.writeU8(221);
44697
- this.writeU32(size);
44698
- } else {
44699
- throw new Error(`Too large array: ${size}`);
44700
- }
44701
- for (const item of object2) {
44702
- this.doEncode(item, depth + 1);
44703
- }
44704
- }
44705
- countWithoutUndefined(object2, keys) {
44706
- let count = 0;
44707
- for (const key of keys) {
44708
- if (object2[key] !== void 0) {
44709
- count++;
44710
- }
44711
- }
44712
- return count;
44713
- }
44714
- encodeMap(object2, depth) {
44715
- const keys = Object.keys(object2);
44716
- if (this.sortKeys) {
44717
- keys.sort();
44718
- }
44719
- const size = this.ignoreUndefined ? this.countWithoutUndefined(object2, keys) : keys.length;
44720
- if (size < 16) {
44721
- this.writeU8(128 + size);
44722
- } else if (size < 65536) {
44723
- this.writeU8(222);
44724
- this.writeU16(size);
44725
- } else if (size < 4294967296) {
44726
- this.writeU8(223);
44727
- this.writeU32(size);
44728
- } else {
44729
- throw new Error(`Too large map object: ${size}`);
44730
- }
44731
- for (const key of keys) {
44732
- const value = object2[key];
44733
- if (!(this.ignoreUndefined && value === void 0)) {
44734
- this.encodeString(key);
44735
- this.doEncode(value, depth + 1);
44736
- }
44737
- }
44738
- }
44739
- encodeExtension(ext) {
44740
- if (typeof ext.data === "function") {
44741
- const data = ext.data(this.pos + 6);
44742
- const size2 = data.length;
44743
- if (size2 >= 4294967296) {
44744
- throw new Error(`Too large extension object: ${size2}`);
44745
- }
44746
- this.writeU8(201);
44747
- this.writeU32(size2);
44748
- this.writeI8(ext.type);
44749
- this.writeU8a(data);
44750
- return;
44751
- }
44752
- const size = ext.data.length;
44753
- if (size === 1) {
44754
- this.writeU8(212);
44755
- } else if (size === 2) {
44756
- this.writeU8(213);
44757
- } else if (size === 4) {
44758
- this.writeU8(214);
44759
- } else if (size === 8) {
44760
- this.writeU8(215);
44761
- } else if (size === 16) {
44762
- this.writeU8(216);
44763
- } else if (size < 256) {
44764
- this.writeU8(199);
44765
- this.writeU8(size);
44766
- } else if (size < 65536) {
44767
- this.writeU8(200);
44768
- this.writeU16(size);
44769
- } else if (size < 4294967296) {
44770
- this.writeU8(201);
44771
- this.writeU32(size);
44772
- } else {
44773
- throw new Error(`Too large extension object: ${size}`);
44774
- }
44775
- this.writeI8(ext.type);
44776
- this.writeU8a(ext.data);
44777
- }
44778
- writeU8(value) {
44779
- this.ensureBufferSizeToWrite(1);
44780
- this.view.setUint8(this.pos, value);
44781
- this.pos++;
44782
- }
44783
- writeU8a(values) {
44784
- const size = values.length;
44785
- this.ensureBufferSizeToWrite(size);
44786
- this.bytes.set(values, this.pos);
44787
- this.pos += size;
44788
- }
44789
- writeI8(value) {
44790
- this.ensureBufferSizeToWrite(1);
44791
- this.view.setInt8(this.pos, value);
44792
- this.pos++;
44793
- }
44794
- writeU16(value) {
44795
- this.ensureBufferSizeToWrite(2);
44796
- this.view.setUint16(this.pos, value);
44797
- this.pos += 2;
44798
- }
44799
- writeI16(value) {
44800
- this.ensureBufferSizeToWrite(2);
44801
- this.view.setInt16(this.pos, value);
44802
- this.pos += 2;
44803
- }
44804
- writeU32(value) {
44805
- this.ensureBufferSizeToWrite(4);
44806
- this.view.setUint32(this.pos, value);
44807
- this.pos += 4;
44808
- }
44809
- writeI32(value) {
44810
- this.ensureBufferSizeToWrite(4);
44811
- this.view.setInt32(this.pos, value);
44812
- this.pos += 4;
44813
- }
44814
- writeF32(value) {
44815
- this.ensureBufferSizeToWrite(4);
44816
- this.view.setFloat32(this.pos, value);
44817
- this.pos += 4;
44818
- }
44819
- writeF64(value) {
44820
- this.ensureBufferSizeToWrite(8);
44821
- this.view.setFloat64(this.pos, value);
44822
- this.pos += 8;
44823
- }
44824
- writeU64(value) {
44825
- this.ensureBufferSizeToWrite(8);
44826
- setUint64(this.view, this.pos, value);
44827
- this.pos += 8;
44828
- }
44829
- writeI64(value) {
44830
- this.ensureBufferSizeToWrite(8);
44831
- setInt64(this.view, this.pos, value);
44832
- this.pos += 8;
44833
- }
44834
- writeBigUint64(value) {
44835
- this.ensureBufferSizeToWrite(8);
44836
- this.view.setBigUint64(this.pos, value);
44837
- this.pos += 8;
44838
- }
44839
- writeBigInt64(value) {
44840
- this.ensureBufferSizeToWrite(8);
44841
- this.view.setBigInt64(this.pos, value);
44842
- this.pos += 8;
44843
- }
44844
- };
44845
-
44846
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/prettyByte.mjs
44847
- function prettyByte(byte) {
44848
- return `${byte < 0 ? "-" : ""}0x${Math.abs(byte).toString(16).padStart(2, "0")}`;
44849
- }
44850
-
44851
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/CachedKeyDecoder.mjs
44852
- var DEFAULT_MAX_KEY_LENGTH = 16;
44853
- var DEFAULT_MAX_LENGTH_PER_KEY = 16;
44854
- var CachedKeyDecoder = class {
44855
- hit = 0;
44856
- miss = 0;
44857
- caches;
44858
- maxKeyLength;
44859
- maxLengthPerKey;
44860
- constructor(maxKeyLength = DEFAULT_MAX_KEY_LENGTH, maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY) {
44861
- this.maxKeyLength = maxKeyLength;
44862
- this.maxLengthPerKey = maxLengthPerKey;
44863
- this.caches = [];
44864
- for (let i = 0; i < this.maxKeyLength; i++) {
44865
- this.caches.push([]);
44866
- }
44867
- }
44868
- canBeCached(byteLength) {
44869
- return byteLength > 0 && byteLength <= this.maxKeyLength;
44870
- }
44871
- find(bytes, inputOffset, byteLength) {
44872
- const records = this.caches[byteLength - 1];
44873
- FIND_CHUNK: for (const record of records) {
44874
- const recordBytes = record.bytes;
44875
- for (let j = 0; j < byteLength; j++) {
44876
- if (recordBytes[j] !== bytes[inputOffset + j]) {
44877
- continue FIND_CHUNK;
44878
- }
44879
- }
44880
- return record.str;
44881
- }
44882
- return null;
44883
- }
44884
- store(bytes, value) {
44885
- const records = this.caches[bytes.length - 1];
44886
- const record = { bytes, str: value };
44887
- if (records.length >= this.maxLengthPerKey) {
44888
- records[Math.random() * records.length | 0] = record;
44889
- } else {
44890
- records.push(record);
44891
- }
44892
- }
44893
- decode(bytes, inputOffset, byteLength) {
44894
- const cachedValue = this.find(bytes, inputOffset, byteLength);
44895
- if (cachedValue != null) {
44896
- this.hit++;
44897
- return cachedValue;
44898
- }
44899
- this.miss++;
44900
- const str = utf8DecodeJs(bytes, inputOffset, byteLength);
44901
- const slicedCopyOfBytes = Uint8Array.prototype.slice.call(bytes, inputOffset, inputOffset + byteLength);
44902
- this.store(slicedCopyOfBytes, str);
44903
- return str;
44904
- }
44905
- };
44906
-
44907
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/Decoder.mjs
44908
- var STATE_ARRAY = "array";
44909
- var STATE_MAP_KEY = "map_key";
44910
- var STATE_MAP_VALUE = "map_value";
44911
- var mapKeyConverter = (key) => {
44912
- if (typeof key === "string" || typeof key === "number") {
44913
- return key;
44914
- }
44915
- throw new DecodeError("The type of key must be string or number but " + typeof key);
44916
- };
44917
- var StackPool = class {
44918
- stack = [];
44919
- stackHeadPosition = -1;
44920
- get length() {
44921
- return this.stackHeadPosition + 1;
44922
- }
44923
- top() {
44924
- return this.stack[this.stackHeadPosition];
44925
- }
44926
- pushArrayState(size) {
44927
- const state = this.getUninitializedStateFromPool();
44928
- state.type = STATE_ARRAY;
44929
- state.position = 0;
44930
- state.size = size;
44931
- state.array = new Array(size);
44932
- }
44933
- pushMapState(size) {
44934
- const state = this.getUninitializedStateFromPool();
44935
- state.type = STATE_MAP_KEY;
44936
- state.readCount = 0;
44937
- state.size = size;
44938
- state.map = {};
44939
- }
44940
- getUninitializedStateFromPool() {
44941
- this.stackHeadPosition++;
44942
- if (this.stackHeadPosition === this.stack.length) {
44943
- const partialState = {
44944
- type: void 0,
44945
- size: 0,
44946
- array: void 0,
44947
- position: 0,
44948
- readCount: 0,
44949
- map: void 0,
44950
- key: null
44951
- };
44952
- this.stack.push(partialState);
44953
- }
44954
- return this.stack[this.stackHeadPosition];
44955
- }
44956
- release(state) {
44957
- const topStackState = this.stack[this.stackHeadPosition];
44958
- if (topStackState !== state) {
44959
- throw new Error("Invalid stack state. Released state is not on top of the stack.");
44960
- }
44961
- if (state.type === STATE_ARRAY) {
44962
- const partialState = state;
44963
- partialState.size = 0;
44964
- partialState.array = void 0;
44965
- partialState.position = 0;
44966
- partialState.type = void 0;
44967
- }
44968
- if (state.type === STATE_MAP_KEY || state.type === STATE_MAP_VALUE) {
44969
- const partialState = state;
44970
- partialState.size = 0;
44971
- partialState.map = void 0;
44972
- partialState.readCount = 0;
44973
- partialState.type = void 0;
44974
- }
44975
- this.stackHeadPosition--;
44976
- }
44977
- reset() {
44978
- this.stack.length = 0;
44979
- this.stackHeadPosition = -1;
44980
- }
44981
- };
44982
- var HEAD_BYTE_REQUIRED = -1;
44983
- var EMPTY_VIEW = new DataView(new ArrayBuffer(0));
44984
- var EMPTY_BYTES = new Uint8Array(EMPTY_VIEW.buffer);
44985
- try {
44986
- EMPTY_VIEW.getInt8(0);
44987
- } catch (e) {
44988
- if (!(e instanceof RangeError)) {
44989
- throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
44990
- }
44991
- }
44992
- var MORE_DATA = new RangeError("Insufficient data");
44993
- var sharedCachedKeyDecoder = new CachedKeyDecoder();
44994
- var Decoder = class _Decoder {
44995
- extensionCodec;
44996
- context;
44997
- useBigInt64;
44998
- rawStrings;
44999
- maxStrLength;
45000
- maxBinLength;
45001
- maxArrayLength;
45002
- maxMapLength;
45003
- maxExtLength;
45004
- keyDecoder;
45005
- mapKeyConverter;
45006
- totalPos = 0;
45007
- pos = 0;
45008
- view = EMPTY_VIEW;
45009
- bytes = EMPTY_BYTES;
45010
- headByte = HEAD_BYTE_REQUIRED;
45011
- stack = new StackPool();
45012
- entered = false;
45013
- constructor(options) {
45014
- this.extensionCodec = options?.extensionCodec ?? ExtensionCodec.defaultCodec;
45015
- this.context = options?.context;
45016
- this.useBigInt64 = options?.useBigInt64 ?? false;
45017
- this.rawStrings = options?.rawStrings ?? false;
45018
- this.maxStrLength = options?.maxStrLength ?? UINT32_MAX;
45019
- this.maxBinLength = options?.maxBinLength ?? UINT32_MAX;
45020
- this.maxArrayLength = options?.maxArrayLength ?? UINT32_MAX;
45021
- this.maxMapLength = options?.maxMapLength ?? UINT32_MAX;
45022
- this.maxExtLength = options?.maxExtLength ?? UINT32_MAX;
45023
- this.keyDecoder = options?.keyDecoder !== void 0 ? options.keyDecoder : sharedCachedKeyDecoder;
45024
- this.mapKeyConverter = options?.mapKeyConverter ?? mapKeyConverter;
45025
- }
45026
- clone() {
45027
- return new _Decoder({
45028
- extensionCodec: this.extensionCodec,
45029
- context: this.context,
45030
- useBigInt64: this.useBigInt64,
45031
- rawStrings: this.rawStrings,
45032
- maxStrLength: this.maxStrLength,
45033
- maxBinLength: this.maxBinLength,
45034
- maxArrayLength: this.maxArrayLength,
45035
- maxMapLength: this.maxMapLength,
45036
- maxExtLength: this.maxExtLength,
45037
- keyDecoder: this.keyDecoder
45038
- });
45039
- }
45040
- reinitializeState() {
45041
- this.totalPos = 0;
45042
- this.headByte = HEAD_BYTE_REQUIRED;
45043
- this.stack.reset();
45044
- }
45045
- setBuffer(buffer) {
45046
- const bytes = ensureUint8Array(buffer);
45047
- this.bytes = bytes;
45048
- this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
45049
- this.pos = 0;
45050
- }
45051
- appendBuffer(buffer) {
45052
- if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining(1)) {
45053
- this.setBuffer(buffer);
45054
- } else {
45055
- const remainingData = this.bytes.subarray(this.pos);
45056
- const newData = ensureUint8Array(buffer);
45057
- const newBuffer = new Uint8Array(remainingData.length + newData.length);
45058
- newBuffer.set(remainingData);
45059
- newBuffer.set(newData, remainingData.length);
45060
- this.setBuffer(newBuffer);
45061
- }
45062
- }
45063
- hasRemaining(size) {
45064
- return this.view.byteLength - this.pos >= size;
45065
- }
45066
- createExtraByteError(posToShow) {
45067
- const { view, pos } = this;
45068
- return new RangeError(`Extra ${view.byteLength - pos} of ${view.byteLength} byte(s) found at buffer[${posToShow}]`);
45069
- }
45070
- /**
45071
- * @throws {@link DecodeError}
45072
- * @throws {@link RangeError}
45073
- */
45074
- decode(buffer) {
45075
- if (this.entered) {
45076
- const instance = this.clone();
45077
- return instance.decode(buffer);
45078
- }
45079
- try {
45080
- this.entered = true;
45081
- this.reinitializeState();
45082
- this.setBuffer(buffer);
45083
- const object2 = this.doDecodeSync();
45084
- if (this.hasRemaining(1)) {
45085
- throw this.createExtraByteError(this.pos);
45086
- }
45087
- return object2;
45088
- } finally {
45089
- this.entered = false;
45090
- }
45091
- }
45092
- *decodeMulti(buffer) {
45093
- if (this.entered) {
45094
- const instance = this.clone();
45095
- yield* instance.decodeMulti(buffer);
45096
- return;
45097
- }
45098
- try {
45099
- this.entered = true;
45100
- this.reinitializeState();
45101
- this.setBuffer(buffer);
45102
- while (this.hasRemaining(1)) {
45103
- yield this.doDecodeSync();
45104
- }
45105
- } finally {
45106
- this.entered = false;
45107
- }
45108
- }
45109
- async decodeAsync(stream) {
45110
- if (this.entered) {
45111
- const instance = this.clone();
45112
- return instance.decodeAsync(stream);
45113
- }
45114
- try {
45115
- this.entered = true;
45116
- let decoded = false;
45117
- let object2;
45118
- for await (const buffer of stream) {
45119
- if (decoded) {
45120
- this.entered = false;
45121
- throw this.createExtraByteError(this.totalPos);
45122
- }
45123
- this.appendBuffer(buffer);
45124
- try {
45125
- object2 = this.doDecodeSync();
45126
- decoded = true;
45127
- } catch (e) {
45128
- if (!(e instanceof RangeError)) {
45129
- throw e;
45130
- }
45131
- }
45132
- this.totalPos += this.pos;
45133
- }
45134
- if (decoded) {
45135
- if (this.hasRemaining(1)) {
45136
- throw this.createExtraByteError(this.totalPos);
45137
- }
45138
- return object2;
45139
- }
45140
- const { headByte, pos, totalPos } = this;
45141
- throw new RangeError(`Insufficient data in parsing ${prettyByte(headByte)} at ${totalPos} (${pos} in the current buffer)`);
45142
- } finally {
45143
- this.entered = false;
45144
- }
45145
- }
45146
- decodeArrayStream(stream) {
45147
- return this.decodeMultiAsync(stream, true);
45148
- }
45149
- decodeStream(stream) {
45150
- return this.decodeMultiAsync(stream, false);
45151
- }
45152
- async *decodeMultiAsync(stream, isArray) {
45153
- if (this.entered) {
45154
- const instance = this.clone();
45155
- yield* instance.decodeMultiAsync(stream, isArray);
45156
- return;
45157
- }
45158
- try {
45159
- this.entered = true;
45160
- let isArrayHeaderRequired = isArray;
45161
- let arrayItemsLeft = -1;
45162
- for await (const buffer of stream) {
45163
- if (isArray && arrayItemsLeft === 0) {
45164
- throw this.createExtraByteError(this.totalPos);
45165
- }
45166
- this.appendBuffer(buffer);
45167
- if (isArrayHeaderRequired) {
45168
- arrayItemsLeft = this.readArraySize();
45169
- isArrayHeaderRequired = false;
45170
- this.complete();
45171
- }
45172
- try {
45173
- while (true) {
45174
- yield this.doDecodeSync();
45175
- if (--arrayItemsLeft === 0) {
45176
- break;
45177
- }
45178
- }
45179
- } catch (e) {
45180
- if (!(e instanceof RangeError)) {
45181
- throw e;
45182
- }
45183
- }
45184
- this.totalPos += this.pos;
45185
- }
45186
- } finally {
45187
- this.entered = false;
45188
- }
45189
- }
45190
- doDecodeSync() {
45191
- DECODE: while (true) {
45192
- const headByte = this.readHeadByte();
45193
- let object2;
45194
- if (headByte >= 224) {
45195
- object2 = headByte - 256;
45196
- } else if (headByte < 192) {
45197
- if (headByte < 128) {
45198
- object2 = headByte;
45199
- } else if (headByte < 144) {
45200
- const size = headByte - 128;
45201
- if (size !== 0) {
45202
- this.pushMapState(size);
45203
- this.complete();
45204
- continue DECODE;
45205
- } else {
45206
- object2 = {};
45207
- }
45208
- } else if (headByte < 160) {
45209
- const size = headByte - 144;
45210
- if (size !== 0) {
45211
- this.pushArrayState(size);
45212
- this.complete();
45213
- continue DECODE;
45214
- } else {
45215
- object2 = [];
45216
- }
45217
- } else {
45218
- const byteLength = headByte - 160;
45219
- object2 = this.decodeString(byteLength, 0);
45220
- }
45221
- } else if (headByte === 192) {
45222
- object2 = null;
45223
- } else if (headByte === 194) {
45224
- object2 = false;
45225
- } else if (headByte === 195) {
45226
- object2 = true;
45227
- } else if (headByte === 202) {
45228
- object2 = this.readF32();
45229
- } else if (headByte === 203) {
45230
- object2 = this.readF64();
45231
- } else if (headByte === 204) {
45232
- object2 = this.readU8();
45233
- } else if (headByte === 205) {
45234
- object2 = this.readU16();
45235
- } else if (headByte === 206) {
45236
- object2 = this.readU32();
45237
- } else if (headByte === 207) {
45238
- if (this.useBigInt64) {
45239
- object2 = this.readU64AsBigInt();
45240
- } else {
45241
- object2 = this.readU64();
45242
- }
45243
- } else if (headByte === 208) {
45244
- object2 = this.readI8();
45245
- } else if (headByte === 209) {
45246
- object2 = this.readI16();
45247
- } else if (headByte === 210) {
45248
- object2 = this.readI32();
45249
- } else if (headByte === 211) {
45250
- if (this.useBigInt64) {
45251
- object2 = this.readI64AsBigInt();
45252
- } else {
45253
- object2 = this.readI64();
45254
- }
45255
- } else if (headByte === 217) {
45256
- const byteLength = this.lookU8();
45257
- object2 = this.decodeString(byteLength, 1);
45258
- } else if (headByte === 218) {
45259
- const byteLength = this.lookU16();
45260
- object2 = this.decodeString(byteLength, 2);
45261
- } else if (headByte === 219) {
45262
- const byteLength = this.lookU32();
45263
- object2 = this.decodeString(byteLength, 4);
45264
- } else if (headByte === 220) {
45265
- const size = this.readU16();
45266
- if (size !== 0) {
45267
- this.pushArrayState(size);
45268
- this.complete();
45269
- continue DECODE;
45270
- } else {
45271
- object2 = [];
45272
- }
45273
- } else if (headByte === 221) {
45274
- const size = this.readU32();
45275
- if (size !== 0) {
45276
- this.pushArrayState(size);
45277
- this.complete();
45278
- continue DECODE;
45279
- } else {
45280
- object2 = [];
45281
- }
45282
- } else if (headByte === 222) {
45283
- const size = this.readU16();
45284
- if (size !== 0) {
45285
- this.pushMapState(size);
45286
- this.complete();
45287
- continue DECODE;
45288
- } else {
45289
- object2 = {};
45290
- }
45291
- } else if (headByte === 223) {
45292
- const size = this.readU32();
45293
- if (size !== 0) {
45294
- this.pushMapState(size);
45295
- this.complete();
45296
- continue DECODE;
45297
- } else {
45298
- object2 = {};
45299
- }
45300
- } else if (headByte === 196) {
45301
- const size = this.lookU8();
45302
- object2 = this.decodeBinary(size, 1);
45303
- } else if (headByte === 197) {
45304
- const size = this.lookU16();
45305
- object2 = this.decodeBinary(size, 2);
45306
- } else if (headByte === 198) {
45307
- const size = this.lookU32();
45308
- object2 = this.decodeBinary(size, 4);
45309
- } else if (headByte === 212) {
45310
- object2 = this.decodeExtension(1, 0);
45311
- } else if (headByte === 213) {
45312
- object2 = this.decodeExtension(2, 0);
45313
- } else if (headByte === 214) {
45314
- object2 = this.decodeExtension(4, 0);
45315
- } else if (headByte === 215) {
45316
- object2 = this.decodeExtension(8, 0);
45317
- } else if (headByte === 216) {
45318
- object2 = this.decodeExtension(16, 0);
45319
- } else if (headByte === 199) {
45320
- const size = this.lookU8();
45321
- object2 = this.decodeExtension(size, 1);
45322
- } else if (headByte === 200) {
45323
- const size = this.lookU16();
45324
- object2 = this.decodeExtension(size, 2);
45325
- } else if (headByte === 201) {
45326
- const size = this.lookU32();
45327
- object2 = this.decodeExtension(size, 4);
45328
- } else {
45329
- throw new DecodeError(`Unrecognized type byte: ${prettyByte(headByte)}`);
45330
- }
45331
- this.complete();
45332
- const stack = this.stack;
45333
- while (stack.length > 0) {
45334
- const state = stack.top();
45335
- if (state.type === STATE_ARRAY) {
45336
- state.array[state.position] = object2;
45337
- state.position++;
45338
- if (state.position === state.size) {
45339
- object2 = state.array;
45340
- stack.release(state);
45341
- } else {
45342
- continue DECODE;
45343
- }
45344
- } else if (state.type === STATE_MAP_KEY) {
45345
- if (object2 === "__proto__") {
45346
- throw new DecodeError("The key __proto__ is not allowed");
45347
- }
45348
- state.key = this.mapKeyConverter(object2);
45349
- state.type = STATE_MAP_VALUE;
45350
- continue DECODE;
45351
- } else {
45352
- state.map[state.key] = object2;
45353
- state.readCount++;
45354
- if (state.readCount === state.size) {
45355
- object2 = state.map;
45356
- stack.release(state);
45357
- } else {
45358
- state.key = null;
45359
- state.type = STATE_MAP_KEY;
45360
- continue DECODE;
45361
- }
45362
- }
45363
- }
45364
- return object2;
45365
- }
45366
- }
45367
- readHeadByte() {
45368
- if (this.headByte === HEAD_BYTE_REQUIRED) {
45369
- this.headByte = this.readU8();
45370
- }
45371
- return this.headByte;
45372
- }
45373
- complete() {
45374
- this.headByte = HEAD_BYTE_REQUIRED;
45375
- }
45376
- readArraySize() {
45377
- const headByte = this.readHeadByte();
45378
- switch (headByte) {
45379
- case 220:
45380
- return this.readU16();
45381
- case 221:
45382
- return this.readU32();
45383
- default: {
45384
- if (headByte < 160) {
45385
- return headByte - 144;
45386
- } else {
45387
- throw new DecodeError(`Unrecognized array type byte: ${prettyByte(headByte)}`);
45388
- }
45389
- }
45390
- }
45391
- }
45392
- pushMapState(size) {
45393
- if (size > this.maxMapLength) {
45394
- throw new DecodeError(`Max length exceeded: map length (${size}) > maxMapLengthLength (${this.maxMapLength})`);
45395
- }
45396
- this.stack.pushMapState(size);
45397
- }
45398
- pushArrayState(size) {
45399
- if (size > this.maxArrayLength) {
45400
- throw new DecodeError(`Max length exceeded: array length (${size}) > maxArrayLength (${this.maxArrayLength})`);
45401
- }
45402
- this.stack.pushArrayState(size);
45403
- }
45404
- decodeString(byteLength, headerOffset) {
45405
- if (!this.rawStrings || this.stateIsMapKey()) {
45406
- return this.decodeUtf8String(byteLength, headerOffset);
45407
- }
45408
- return this.decodeBinary(byteLength, headerOffset);
45409
- }
45410
- /**
45411
- * @throws {@link RangeError}
45412
- */
45413
- decodeUtf8String(byteLength, headerOffset) {
45414
- if (byteLength > this.maxStrLength) {
45415
- throw new DecodeError(`Max length exceeded: UTF-8 byte length (${byteLength}) > maxStrLength (${this.maxStrLength})`);
45416
- }
45417
- if (this.bytes.byteLength < this.pos + headerOffset + byteLength) {
45418
- throw MORE_DATA;
45419
- }
45420
- const offset = this.pos + headerOffset;
45421
- let object2;
45422
- if (this.stateIsMapKey() && this.keyDecoder?.canBeCached(byteLength)) {
45423
- object2 = this.keyDecoder.decode(this.bytes, offset, byteLength);
45424
- } else {
45425
- object2 = utf8Decode(this.bytes, offset, byteLength);
45426
- }
45427
- this.pos += headerOffset + byteLength;
45428
- return object2;
45429
- }
45430
- stateIsMapKey() {
45431
- if (this.stack.length > 0) {
45432
- const state = this.stack.top();
45433
- return state.type === STATE_MAP_KEY;
45434
- }
45435
- return false;
45436
- }
45437
- /**
45438
- * @throws {@link RangeError}
45439
- */
45440
- decodeBinary(byteLength, headOffset) {
45441
- if (byteLength > this.maxBinLength) {
45442
- throw new DecodeError(`Max length exceeded: bin length (${byteLength}) > maxBinLength (${this.maxBinLength})`);
45443
- }
45444
- if (!this.hasRemaining(byteLength + headOffset)) {
45445
- throw MORE_DATA;
45446
- }
45447
- const offset = this.pos + headOffset;
45448
- const object2 = this.bytes.subarray(offset, offset + byteLength);
45449
- this.pos += headOffset + byteLength;
45450
- return object2;
45451
- }
45452
- decodeExtension(size, headOffset) {
45453
- if (size > this.maxExtLength) {
45454
- throw new DecodeError(`Max length exceeded: ext length (${size}) > maxExtLength (${this.maxExtLength})`);
45455
- }
45456
- const extType = this.view.getInt8(this.pos + headOffset);
45457
- const data = this.decodeBinary(
45458
- size,
45459
- headOffset + 1
45460
- /* extType */
45461
- );
45462
- return this.extensionCodec.decode(data, extType, this.context);
45463
- }
45464
- lookU8() {
45465
- return this.view.getUint8(this.pos);
45466
- }
45467
- lookU16() {
45468
- return this.view.getUint16(this.pos);
45469
- }
45470
- lookU32() {
45471
- return this.view.getUint32(this.pos);
45472
- }
45473
- readU8() {
45474
- const value = this.view.getUint8(this.pos);
45475
- this.pos++;
45476
- return value;
45477
- }
45478
- readI8() {
45479
- const value = this.view.getInt8(this.pos);
45480
- this.pos++;
45481
- return value;
45482
- }
45483
- readU16() {
45484
- const value = this.view.getUint16(this.pos);
45485
- this.pos += 2;
45486
- return value;
45487
- }
45488
- readI16() {
45489
- const value = this.view.getInt16(this.pos);
45490
- this.pos += 2;
45491
- return value;
45492
- }
45493
- readU32() {
45494
- const value = this.view.getUint32(this.pos);
45495
- this.pos += 4;
45496
- return value;
45497
- }
45498
- readI32() {
45499
- const value = this.view.getInt32(this.pos);
45500
- this.pos += 4;
45501
- return value;
45502
- }
45503
- readU64() {
45504
- const value = getUint64(this.view, this.pos);
45505
- this.pos += 8;
45506
- return value;
45507
- }
45508
- readI64() {
45509
- const value = getInt64(this.view, this.pos);
45510
- this.pos += 8;
45511
- return value;
45512
- }
45513
- readU64AsBigInt() {
45514
- const value = this.view.getBigUint64(this.pos);
45515
- this.pos += 8;
45516
- return value;
45517
- }
45518
- readI64AsBigInt() {
45519
- const value = this.view.getBigInt64(this.pos);
45520
- this.pos += 8;
45521
- return value;
45522
- }
45523
- readF32() {
45524
- const value = this.view.getFloat32(this.pos);
45525
- this.pos += 4;
45526
- return value;
45527
- }
45528
- readF64() {
45529
- const value = this.view.getFloat64(this.pos);
45530
- this.pos += 8;
45531
- return value;
45532
- }
45533
- };
45534
-
45535
- // src/vendor/titan/client.ts
45536
44104
  var SUBPROTOCOL = "v1.api.titan.ag";
45537
44105
  var UINT64_MAX = (1n << 64n) - 1n;
45538
44106
  function toBigInt(value) {
@@ -45585,8 +44153,8 @@ var StreamError = class _StreamError extends Error {
45585
44153
  this.errorMessage = message;
45586
44154
  }
45587
44155
  };
45588
- var encoder = new Encoder({ useBigInt64: true });
45589
- var decoder = new Decoder({ useBigInt64: true });
44156
+ var encoder = new msgpack.Encoder({ useBigInt64: true });
44157
+ var decoder = new msgpack.Decoder({ useBigInt64: true });
45590
44158
  var V1Client = class _V1Client {
45591
44159
  socket;
45592
44160
  nextId = 0;
@@ -48383,7 +46951,6 @@ async function buildRepayWithCollatFlashloanTx({
48383
46951
  destinationTokenAccount,
48384
46952
  swapOpts,
48385
46953
  sizeConstraint: swapConstraints.sizeConstraint,
48386
- maxSwapAccounts: swapConstraints.maxSwapWritableAccounts,
48387
46954
  maxSwapTotalAccounts: swapConstraints.maxSwapTotalAccounts
48388
46955
  });
48389
46956
  sizeConstraintUsed = swapConstraints.sizeConstraint;
@@ -48582,12 +47149,11 @@ async function buildRepayWithCollatFlashloanTx({
48582
47149
  isSync: true
48583
47150
  });
48584
47151
  const txSize = getTxSize(flashloanTx);
48585
- const writableKeys = getWritableAccountKeys(flashloanTx);
48586
47152
  const totalKeys = getTotalAccountKeys(flashloanTx);
48587
- if (txSize > MAX_TX_SIZE || writableKeys > MAX_WRITABLE_ACCOUNTS || totalKeys > MAX_ACCOUNT_LOCKS) {
47153
+ if (txSize > MAX_TX_SIZE || totalKeys > MAX_ACCOUNT_LOCKS) {
48588
47154
  throw TransactionBuildingError.swapSizeExceededRepay(
48589
47155
  txSize,
48590
- writableKeys,
47156
+ totalKeys,
48591
47157
  swapOpts.swapConfig?.provider
48592
47158
  );
48593
47159
  }
@@ -48732,26 +47298,20 @@ function computeFlashLoanNonSwapBudget({
48732
47298
  }).compileToV0Message(addressLookupTableAccounts);
48733
47299
  const nonSwapSize = new web3_js.VersionedTransaction(nonSwapMsg).serialize().length;
48734
47300
  const { header, staticAccountKeys, addressTableLookups } = nonSwapMsg;
48735
- const writableStatic = staticAccountKeys.length - header.numReadonlySignedAccounts - header.numReadonlyUnsignedAccounts;
48736
- const writableLut = addressTableLookups.reduce((s, l) => s + l.writableIndexes.length, 0);
48737
- const nonSwapWritable = writableStatic + writableLut;
48738
47301
  const nonSwapTotal = staticAccountKeys.length + addressTableLookups.reduce(
48739
47302
  (s, l) => s + l.writableIndexes.length + l.readonlyIndexes.length,
48740
47303
  0
48741
47304
  );
48742
47305
  const sizeConstraint = MAX_TX_SIZE - nonSwapSize - SWAP_MERGE_OVERHEAD;
48743
- const maxSwapWritableAccounts = MAX_WRITABLE_ACCOUNTS - nonSwapWritable;
48744
47306
  const maxSwapTotalAccounts = MAX_ACCOUNT_LOCKS - nonSwapTotal;
48745
47307
  console.log("[flashloan-budget]", {
48746
47308
  method: "compiled",
48747
47309
  nonSwapSize,
48748
- nonSwapWritable,
48749
47310
  nonSwapTotal,
48750
47311
  sizeConstraint,
48751
- maxSwapWritableAccounts,
48752
47312
  maxSwapTotalAccounts
48753
47313
  });
48754
- return { sizeConstraint, maxSwapWritableAccounts, maxSwapTotalAccounts };
47314
+ return { sizeConstraint, maxSwapTotalAccounts };
48755
47315
  }
48756
47316
  function compileFlashloanPrecheck({
48757
47317
  allIxs,
@@ -49323,7 +47883,6 @@ async function buildLoopFlashloanTx({
49323
47883
  destinationTokenAccount,
49324
47884
  swapOpts,
49325
47885
  sizeConstraint: swapConstraints.sizeConstraint,
49326
- maxSwapAccounts: swapConstraints.maxSwapWritableAccounts,
49327
47886
  maxSwapTotalAccounts: swapConstraints.maxSwapTotalAccounts
49328
47887
  });
49329
47888
  sizeConstraintUsed = swapConstraints.sizeConstraint;
@@ -49466,12 +48025,11 @@ async function buildLoopFlashloanTx({
49466
48025
  ixs: allNonFlIxs
49467
48026
  });
49468
48027
  const txSize = getTxSize(flashloanTx);
49469
- const writableKeys = getWritableAccountKeys(flashloanTx);
49470
48028
  const totalKeys = getTotalAccountKeys(flashloanTx);
49471
- if (txSize > MAX_TX_SIZE || writableKeys > MAX_WRITABLE_ACCOUNTS || totalKeys > MAX_ACCOUNT_LOCKS) {
48029
+ if (txSize > MAX_TX_SIZE || totalKeys > MAX_ACCOUNT_LOCKS) {
49472
48030
  throw TransactionBuildingError.swapSizeExceededLoop(
49473
48031
  txSize,
49474
- writableKeys,
48032
+ totalKeys,
49475
48033
  swapOpts.swapConfig?.provider
49476
48034
  );
49477
48035
  }
@@ -49783,7 +48341,6 @@ async function buildSwapCollateralFlashloanTx({
49783
48341
  destinationTokenAccount,
49784
48342
  swapOpts,
49785
48343
  sizeConstraint: swapConstraints.sizeConstraint,
49786
- maxSwapAccounts: swapConstraints.maxSwapWritableAccounts,
49787
48344
  maxSwapTotalAccounts: swapConstraints.maxSwapTotalAccounts
49788
48345
  });
49789
48346
  sizeConstraintUsed = swapConstraints.sizeConstraint;
@@ -49911,12 +48468,11 @@ async function buildSwapCollateralFlashloanTx({
49911
48468
  isSync: true
49912
48469
  });
49913
48470
  const txSize = getTxSize(flashloanTx);
49914
- const writableKeys = getWritableAccountKeys(flashloanTx);
49915
48471
  const totalKeys = getTotalAccountKeys(flashloanTx);
49916
- if (txSize > MAX_TX_SIZE || writableKeys > MAX_WRITABLE_ACCOUNTS || totalKeys > MAX_ACCOUNT_LOCKS) {
48472
+ if (txSize > MAX_TX_SIZE || totalKeys > MAX_ACCOUNT_LOCKS) {
49917
48473
  throw TransactionBuildingError.swapSizeExceededLoop(
49918
48474
  txSize,
49919
- writableKeys,
48475
+ totalKeys,
49920
48476
  swapOpts.swapConfig?.provider
49921
48477
  );
49922
48478
  }
@@ -50102,7 +48658,6 @@ async function buildSwapDebtFlashloanTx({
50102
48658
  destinationTokenAccount,
50103
48659
  swapOpts,
50104
48660
  sizeConstraint: swapConstraints.sizeConstraint,
50105
- maxSwapAccounts: swapConstraints.maxSwapWritableAccounts,
50106
48661
  maxSwapTotalAccounts: swapConstraints.maxSwapTotalAccounts
50107
48662
  });
50108
48663
  const { quoteResponse } = swapResponses;
@@ -50174,12 +48729,11 @@ async function buildSwapDebtFlashloanTx({
50174
48729
  isSync: true
50175
48730
  });
50176
48731
  const txSize = getTxSize(flashloanTx);
50177
- const writableKeys = getWritableAccountKeys(flashloanTx);
50178
48732
  const totalKeys = getTotalAccountKeys(flashloanTx);
50179
- if (txSize > MAX_TX_SIZE || writableKeys > MAX_WRITABLE_ACCOUNTS || totalKeys > MAX_ACCOUNT_LOCKS) {
48733
+ if (txSize > MAX_TX_SIZE || totalKeys > MAX_ACCOUNT_LOCKS) {
50180
48734
  throw TransactionBuildingError.swapSizeExceededLoop(
50181
48735
  txSize,
50182
- writableKeys,
48736
+ totalKeys,
50183
48737
  swapOpts.swapConfig?.provider
50184
48738
  );
50185
48739
  }
@@ -50927,7 +49481,10 @@ async function getTitanSwapIxsViaWebSocket(params, feeAccount) {
50927
49481
  const swapInstructions = bestRoute.instructions.map(deserializeTitanInstruction);
50928
49482
  const lutPubkeys = bestRoute.addressLookupTables.map((lutBytes) => new web3_js.PublicKey(lutBytes));
50929
49483
  const addressLookupTableAddresses = await resolveLookupTables(connection, lutPubkeys);
50930
- const quoteResponse = buildSwapQuoteResult(bestRoute, swapMode);
49484
+ const quoteResponse = {
49485
+ ...buildSwapQuoteResult(bestRoute, swapMode),
49486
+ provider: "TITAN" /* TITAN */
49487
+ };
50931
49488
  return {
50932
49489
  swapInstructions,
50933
49490
  setupInstructions: [],
@@ -51004,7 +49561,10 @@ async function getTitanSwapIxsViaHttpProxy(params, feeAccount) {
51004
49561
  (b64) => new web3_js.PublicKey(Buffer.from(b64, "base64"))
51005
49562
  );
51006
49563
  const addressLookupTableAddresses = await resolveLookupTables(connection, lutPubkeys);
51007
- const quoteResponse = buildSwapQuoteResult(bestRoute, swapMode);
49564
+ const quoteResponse = {
49565
+ ...buildSwapQuoteResult(bestRoute, swapMode),
49566
+ provider: "TITAN" /* TITAN */
49567
+ };
51008
49568
  return {
51009
49569
  swapInstructions,
51010
49570
  setupInstructions: [],
@@ -51055,7 +49615,10 @@ async function getTitanExactOutViaWebSocket(params) {
51055
49615
  if (!bestRoute) {
51056
49616
  throw new Error(`No Titan ExactOut routes found for ${inputMint} -> ${outputMint}`);
51057
49617
  }
51058
- const quoteResult = buildSwapQuoteResult(bestRoute, "ExactOut");
49618
+ const quoteResult = {
49619
+ ...buildSwapQuoteResult(bestRoute, "ExactOut"),
49620
+ provider: "TITAN" /* TITAN */
49621
+ };
51059
49622
  return {
51060
49623
  otherAmountThreshold: quoteResult.otherAmountThreshold,
51061
49624
  quoteResult
@@ -51096,7 +49659,8 @@ async function getTitanExactOutViaHttpProxy(params) {
51096
49659
  inAmount: String(data.inAmount),
51097
49660
  outAmount: String(data.outAmount),
51098
49661
  otherAmountThreshold: data.otherAmountThreshold,
51099
- slippageBps: data.slippageBps
49662
+ slippageBps: data.slippageBps,
49663
+ provider: "TITAN" /* TITAN */
51100
49664
  };
51101
49665
  return {
51102
49666
  otherAmountThreshold: data.otherAmountThreshold,
@@ -51116,8 +49680,7 @@ function getSwapProviderFn({
51116
49680
  connection,
51117
49681
  destinationTokenAccount,
51118
49682
  swapOpts,
51119
- sizeConstraint,
51120
- maxSwapAccounts
49683
+ sizeConstraint
51121
49684
  }) {
51122
49685
  switch (attemptProvider) {
51123
49686
  case "TITAN" /* TITAN */:
@@ -51131,7 +49694,6 @@ function getSwapProviderFn({
51131
49694
  platformFeeBps: swapOpts.swapConfig?.platformFeeBps,
51132
49695
  directRoutesOnly: swapOpts.swapConfig?.directRoutesOnly,
51133
49696
  sizeConstraint,
51134
- maxSwapAccounts,
51135
49697
  maxSwapTotalAccounts
51136
49698
  },
51137
49699
  authority,
@@ -51155,7 +49717,7 @@ function getSwapProviderFn({
51155
49717
  connection,
51156
49718
  destinationTokenAccount,
51157
49719
  apiConfig,
51158
- maxSwapAccounts
49720
+ maxSwapAccounts: maxSwapTotalAccounts
51159
49721
  });
51160
49722
  default:
51161
49723
  return void 0;
@@ -51208,7 +49770,7 @@ var getSwapIxsForFlashloan = async (params) => {
51208
49770
  destinationTokenAccount,
51209
49771
  swapOpts,
51210
49772
  sizeConstraint,
51211
- maxSwapAccounts
49773
+ maxSwapTotalAccounts
51212
49774
  } = params;
51213
49775
  if (swapOpts.swapIxs) {
51214
49776
  return {
@@ -51241,8 +49803,7 @@ var getSwapIxsForFlashloan = async (params) => {
51241
49803
  connection,
51242
49804
  destinationTokenAccount,
51243
49805
  swapOpts,
51244
- sizeConstraint,
51245
- maxSwapAccounts
49806
+ sizeConstraint
51246
49807
  });
51247
49808
  if (!fn) continue;
51248
49809
  try {
@@ -51310,7 +49871,8 @@ function mapJupiterQuoteToSwapQuoteResult(quote) {
51310
49871
  } : void 0,
51311
49872
  priceImpactPct: quote.priceImpactPct,
51312
49873
  contextSlot: quote.contextSlot,
51313
- timeTaken: quote.timeTaken
49874
+ timeTaken: quote.timeTaken,
49875
+ provider: "JUPITER" /* JUPITER */
51314
49876
  };
51315
49877
  }
51316
49878
 
@@ -52630,7 +51192,7 @@ function computeMaxLeverage(depositBank, borrowBank, opts) {
52630
51192
  ltv
52631
51193
  };
52632
51194
  }
52633
- function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank, depositOracleInfo, borrowOracleInfo, opts) {
51195
+ function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank, depositPriceUsd, borrowPriceUsd, opts) {
52634
51196
  const initialCollateral = toBigNumber(principal);
52635
51197
  const { maxLeverage } = computeMaxLeverage(depositBank, borrowBank, opts);
52636
51198
  let clampedLeverage = targetLeverage;
@@ -52645,7 +51207,7 @@ function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank
52645
51207
  }
52646
51208
  const totalDepositAmount = initialCollateral.times(new BigNumber3__default.default(clampedLeverage));
52647
51209
  const additionalDepositAmount = totalDepositAmount.minus(initialCollateral);
52648
- const totalBorrowAmount = additionalDepositAmount.times(depositOracleInfo.priceWeighted.lowestPrice).div(borrowOracleInfo.priceWeighted.highestPrice);
51210
+ const totalBorrowAmount = additionalDepositAmount.times(new BigNumber3__default.default(depositPriceUsd)).div(new BigNumber3__default.default(borrowPriceUsd));
52649
51211
  return {
52650
51212
  totalBorrowAmount: totalBorrowAmount.decimalPlaces(
52651
51213
  borrowBank.mintDecimals,
@@ -56090,7 +54652,6 @@ exports.MAX_ACCOUNT_LOCKS = MAX_ACCOUNT_LOCKS;
56090
54652
  exports.MAX_CONFIDENCE_INTERVAL_RATIO = MAX_CONFIDENCE_INTERVAL_RATIO;
56091
54653
  exports.MAX_TX_SIZE = MAX_TX_SIZE;
56092
54654
  exports.MAX_U64 = MAX_U64;
56093
- exports.MAX_WRITABLE_ACCOUNTS = MAX_WRITABLE_ACCOUNTS;
56094
54655
  exports.MPL_METADATA_PROGRAM_ID = MPL_METADATA_PROGRAM_ID;
56095
54656
  exports.MarginRequirementType = MarginRequirementType;
56096
54657
  exports.MarginfiAccount = MarginfiAccount;