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

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
@@ -11,6 +11,7 @@ import { deserialize } from 'borsh';
11
11
  import * as borsh from '@coral-xyz/borsh';
12
12
  import { struct as struct$1, bool as bool$1, publicKey as publicKey$1, array as array$1, u64 as u64$1, u8 as u8$1, u32 as u32$1, u128 } from '@coral-xyz/borsh';
13
13
  import WebSocket from 'ws';
14
+ import { Encoder, Decoder } from '@msgpack/msgpack';
14
15
  import { SwapApi, Configuration, createJupiterApiClient } from '@jup-ag/api';
15
16
  import { AnchorUtils, PullFeed } from '@switchboard-xyz/on-demand';
16
17
  import { CrossbarClient } from '@switchboard-xyz/common';
@@ -44074,1438 +44075,6 @@ function makeUpdateJupLendRate({ lendingState }) {
44074
44075
  lendingState.rewardsRateModel
44075
44076
  );
44076
44077
  }
44077
-
44078
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/utf8.mjs
44079
- function utf8Count(str) {
44080
- const strLength = str.length;
44081
- let byteLength = 0;
44082
- let pos = 0;
44083
- while (pos < strLength) {
44084
- let value = str.charCodeAt(pos++);
44085
- if ((value & 4294967168) === 0) {
44086
- byteLength++;
44087
- continue;
44088
- } else if ((value & 4294965248) === 0) {
44089
- byteLength += 2;
44090
- } else {
44091
- if (value >= 55296 && value <= 56319) {
44092
- if (pos < strLength) {
44093
- const extra = str.charCodeAt(pos);
44094
- if ((extra & 64512) === 56320) {
44095
- ++pos;
44096
- value = ((value & 1023) << 10) + (extra & 1023) + 65536;
44097
- }
44098
- }
44099
- }
44100
- if ((value & 4294901760) === 0) {
44101
- byteLength += 3;
44102
- } else {
44103
- byteLength += 4;
44104
- }
44105
- }
44106
- }
44107
- return byteLength;
44108
- }
44109
- function utf8EncodeJs(str, output, outputOffset) {
44110
- const strLength = str.length;
44111
- let offset = outputOffset;
44112
- let pos = 0;
44113
- while (pos < strLength) {
44114
- let value = str.charCodeAt(pos++);
44115
- if ((value & 4294967168) === 0) {
44116
- output[offset++] = value;
44117
- continue;
44118
- } else if ((value & 4294965248) === 0) {
44119
- output[offset++] = value >> 6 & 31 | 192;
44120
- } else {
44121
- if (value >= 55296 && value <= 56319) {
44122
- if (pos < strLength) {
44123
- const extra = str.charCodeAt(pos);
44124
- if ((extra & 64512) === 56320) {
44125
- ++pos;
44126
- value = ((value & 1023) << 10) + (extra & 1023) + 65536;
44127
- }
44128
- }
44129
- }
44130
- if ((value & 4294901760) === 0) {
44131
- output[offset++] = value >> 12 & 15 | 224;
44132
- output[offset++] = value >> 6 & 63 | 128;
44133
- } else {
44134
- output[offset++] = value >> 18 & 7 | 240;
44135
- output[offset++] = value >> 12 & 63 | 128;
44136
- output[offset++] = value >> 6 & 63 | 128;
44137
- }
44138
- }
44139
- output[offset++] = value & 63 | 128;
44140
- }
44141
- }
44142
- var sharedTextEncoder = new TextEncoder();
44143
- var TEXT_ENCODER_THRESHOLD = 50;
44144
- function utf8EncodeTE(str, output, outputOffset) {
44145
- sharedTextEncoder.encodeInto(str, output.subarray(outputOffset));
44146
- }
44147
- function utf8Encode(str, output, outputOffset) {
44148
- if (str.length > TEXT_ENCODER_THRESHOLD) {
44149
- utf8EncodeTE(str, output, outputOffset);
44150
- } else {
44151
- utf8EncodeJs(str, output, outputOffset);
44152
- }
44153
- }
44154
- var CHUNK_SIZE = 4096;
44155
- function utf8DecodeJs(bytes, inputOffset, byteLength) {
44156
- let offset = inputOffset;
44157
- const end = offset + byteLength;
44158
- const units = [];
44159
- let result = "";
44160
- while (offset < end) {
44161
- const byte1 = bytes[offset++];
44162
- if ((byte1 & 128) === 0) {
44163
- units.push(byte1);
44164
- } else if ((byte1 & 224) === 192) {
44165
- const byte2 = bytes[offset++] & 63;
44166
- units.push((byte1 & 31) << 6 | byte2);
44167
- } else if ((byte1 & 240) === 224) {
44168
- const byte2 = bytes[offset++] & 63;
44169
- const byte3 = bytes[offset++] & 63;
44170
- units.push((byte1 & 31) << 12 | byte2 << 6 | byte3);
44171
- } else if ((byte1 & 248) === 240) {
44172
- const byte2 = bytes[offset++] & 63;
44173
- const byte3 = bytes[offset++] & 63;
44174
- const byte4 = bytes[offset++] & 63;
44175
- let unit = (byte1 & 7) << 18 | byte2 << 12 | byte3 << 6 | byte4;
44176
- if (unit > 65535) {
44177
- unit -= 65536;
44178
- units.push(unit >>> 10 & 1023 | 55296);
44179
- unit = 56320 | unit & 1023;
44180
- }
44181
- units.push(unit);
44182
- } else {
44183
- units.push(byte1);
44184
- }
44185
- if (units.length >= CHUNK_SIZE) {
44186
- result += String.fromCharCode(...units);
44187
- units.length = 0;
44188
- }
44189
- }
44190
- if (units.length > 0) {
44191
- result += String.fromCharCode(...units);
44192
- }
44193
- return result;
44194
- }
44195
- var sharedTextDecoder = new TextDecoder();
44196
- var TEXT_DECODER_THRESHOLD = 200;
44197
- function utf8DecodeTD(bytes, inputOffset, byteLength) {
44198
- const stringBytes = bytes.subarray(inputOffset, inputOffset + byteLength);
44199
- return sharedTextDecoder.decode(stringBytes);
44200
- }
44201
- function utf8Decode(bytes, inputOffset, byteLength) {
44202
- if (byteLength > TEXT_DECODER_THRESHOLD) {
44203
- return utf8DecodeTD(bytes, inputOffset, byteLength);
44204
- } else {
44205
- return utf8DecodeJs(bytes, inputOffset, byteLength);
44206
- }
44207
- }
44208
-
44209
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/ExtData.mjs
44210
- var ExtData = class {
44211
- type;
44212
- data;
44213
- constructor(type, data) {
44214
- this.type = type;
44215
- this.data = data;
44216
- }
44217
- };
44218
-
44219
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/DecodeError.mjs
44220
- var DecodeError = class _DecodeError extends Error {
44221
- constructor(message) {
44222
- super(message);
44223
- const proto = Object.create(_DecodeError.prototype);
44224
- Object.setPrototypeOf(this, proto);
44225
- Object.defineProperty(this, "name", {
44226
- configurable: true,
44227
- enumerable: false,
44228
- value: _DecodeError.name
44229
- });
44230
- }
44231
- };
44232
-
44233
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/int.mjs
44234
- var UINT32_MAX = 4294967295;
44235
- function setUint64(view, offset, value) {
44236
- const high = value / 4294967296;
44237
- const low = value;
44238
- view.setUint32(offset, high);
44239
- view.setUint32(offset + 4, low);
44240
- }
44241
- function setInt64(view, offset, value) {
44242
- const high = Math.floor(value / 4294967296);
44243
- const low = value;
44244
- view.setUint32(offset, high);
44245
- view.setUint32(offset + 4, low);
44246
- }
44247
- function getInt64(view, offset) {
44248
- const high = view.getInt32(offset);
44249
- const low = view.getUint32(offset + 4);
44250
- return high * 4294967296 + low;
44251
- }
44252
- function getUint64(view, offset) {
44253
- const high = view.getUint32(offset);
44254
- const low = view.getUint32(offset + 4);
44255
- return high * 4294967296 + low;
44256
- }
44257
-
44258
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/timestamp.mjs
44259
- var EXT_TIMESTAMP = -1;
44260
- var TIMESTAMP32_MAX_SEC = 4294967296 - 1;
44261
- var TIMESTAMP64_MAX_SEC = 17179869184 - 1;
44262
- function encodeTimeSpecToTimestamp({ sec, nsec }) {
44263
- if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) {
44264
- if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {
44265
- const rv = new Uint8Array(4);
44266
- const view = new DataView(rv.buffer);
44267
- view.setUint32(0, sec);
44268
- return rv;
44269
- } else {
44270
- const secHigh = sec / 4294967296;
44271
- const secLow = sec & 4294967295;
44272
- const rv = new Uint8Array(8);
44273
- const view = new DataView(rv.buffer);
44274
- view.setUint32(0, nsec << 2 | secHigh & 3);
44275
- view.setUint32(4, secLow);
44276
- return rv;
44277
- }
44278
- } else {
44279
- const rv = new Uint8Array(12);
44280
- const view = new DataView(rv.buffer);
44281
- view.setUint32(0, nsec);
44282
- setInt64(view, 4, sec);
44283
- return rv;
44284
- }
44285
- }
44286
- function encodeDateToTimeSpec(date) {
44287
- const msec = date.getTime();
44288
- const sec = Math.floor(msec / 1e3);
44289
- const nsec = (msec - sec * 1e3) * 1e6;
44290
- const nsecInSec = Math.floor(nsec / 1e9);
44291
- return {
44292
- sec: sec + nsecInSec,
44293
- nsec: nsec - nsecInSec * 1e9
44294
- };
44295
- }
44296
- function encodeTimestampExtension(object2) {
44297
- if (object2 instanceof Date) {
44298
- const timeSpec = encodeDateToTimeSpec(object2);
44299
- return encodeTimeSpecToTimestamp(timeSpec);
44300
- } else {
44301
- return null;
44302
- }
44303
- }
44304
- function decodeTimestampToTimeSpec(data) {
44305
- const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
44306
- switch (data.byteLength) {
44307
- case 4: {
44308
- const sec = view.getUint32(0);
44309
- const nsec = 0;
44310
- return { sec, nsec };
44311
- }
44312
- case 8: {
44313
- const nsec30AndSecHigh2 = view.getUint32(0);
44314
- const secLow32 = view.getUint32(4);
44315
- const sec = (nsec30AndSecHigh2 & 3) * 4294967296 + secLow32;
44316
- const nsec = nsec30AndSecHigh2 >>> 2;
44317
- return { sec, nsec };
44318
- }
44319
- case 12: {
44320
- const sec = getInt64(view, 4);
44321
- const nsec = view.getUint32(0);
44322
- return { sec, nsec };
44323
- }
44324
- default:
44325
- throw new DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${data.length}`);
44326
- }
44327
- }
44328
- function decodeTimestampExtension(data) {
44329
- const timeSpec = decodeTimestampToTimeSpec(data);
44330
- return new Date(timeSpec.sec * 1e3 + timeSpec.nsec / 1e6);
44331
- }
44332
- var timestampExtension = {
44333
- type: EXT_TIMESTAMP,
44334
- encode: encodeTimestampExtension,
44335
- decode: decodeTimestampExtension
44336
- };
44337
-
44338
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/ExtensionCodec.mjs
44339
- var ExtensionCodec = class _ExtensionCodec {
44340
- static defaultCodec = new _ExtensionCodec();
44341
- // ensures ExtensionCodecType<X> matches ExtensionCodec<X>
44342
- // this will make type errors a lot more clear
44343
- // eslint-disable-next-line @typescript-eslint/naming-convention
44344
- __brand;
44345
- // built-in extensions
44346
- builtInEncoders = [];
44347
- builtInDecoders = [];
44348
- // custom extensions
44349
- encoders = [];
44350
- decoders = [];
44351
- constructor() {
44352
- this.register(timestampExtension);
44353
- }
44354
- register({ type, encode, decode }) {
44355
- if (type >= 0) {
44356
- this.encoders[type] = encode;
44357
- this.decoders[type] = decode;
44358
- } else {
44359
- const index = -1 - type;
44360
- this.builtInEncoders[index] = encode;
44361
- this.builtInDecoders[index] = decode;
44362
- }
44363
- }
44364
- tryToEncode(object2, context) {
44365
- for (let i = 0; i < this.builtInEncoders.length; i++) {
44366
- const encodeExt = this.builtInEncoders[i];
44367
- if (encodeExt != null) {
44368
- const data = encodeExt(object2, context);
44369
- if (data != null) {
44370
- const type = -1 - i;
44371
- return new ExtData(type, data);
44372
- }
44373
- }
44374
- }
44375
- for (let i = 0; i < this.encoders.length; i++) {
44376
- const encodeExt = this.encoders[i];
44377
- if (encodeExt != null) {
44378
- const data = encodeExt(object2, context);
44379
- if (data != null) {
44380
- const type = i;
44381
- return new ExtData(type, data);
44382
- }
44383
- }
44384
- }
44385
- if (object2 instanceof ExtData) {
44386
- return object2;
44387
- }
44388
- return null;
44389
- }
44390
- decode(data, type, context) {
44391
- const decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];
44392
- if (decodeExt) {
44393
- return decodeExt(data, type, context);
44394
- } else {
44395
- return new ExtData(type, data);
44396
- }
44397
- }
44398
- };
44399
-
44400
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/typedArrays.mjs
44401
- function isArrayBufferLike(buffer) {
44402
- return buffer instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && buffer instanceof SharedArrayBuffer;
44403
- }
44404
- function ensureUint8Array(buffer) {
44405
- if (buffer instanceof Uint8Array) {
44406
- return buffer;
44407
- } else if (ArrayBuffer.isView(buffer)) {
44408
- return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
44409
- } else if (isArrayBufferLike(buffer)) {
44410
- return new Uint8Array(buffer);
44411
- } else {
44412
- return Uint8Array.from(buffer);
44413
- }
44414
- }
44415
-
44416
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/Encoder.mjs
44417
- var DEFAULT_MAX_DEPTH = 100;
44418
- var DEFAULT_INITIAL_BUFFER_SIZE = 2048;
44419
- var Encoder = class _Encoder {
44420
- extensionCodec;
44421
- context;
44422
- useBigInt64;
44423
- maxDepth;
44424
- initialBufferSize;
44425
- sortKeys;
44426
- forceFloat32;
44427
- ignoreUndefined;
44428
- forceIntegerToFloat;
44429
- pos;
44430
- view;
44431
- bytes;
44432
- entered = false;
44433
- constructor(options) {
44434
- this.extensionCodec = options?.extensionCodec ?? ExtensionCodec.defaultCodec;
44435
- this.context = options?.context;
44436
- this.useBigInt64 = options?.useBigInt64 ?? false;
44437
- this.maxDepth = options?.maxDepth ?? DEFAULT_MAX_DEPTH;
44438
- this.initialBufferSize = options?.initialBufferSize ?? DEFAULT_INITIAL_BUFFER_SIZE;
44439
- this.sortKeys = options?.sortKeys ?? false;
44440
- this.forceFloat32 = options?.forceFloat32 ?? false;
44441
- this.ignoreUndefined = options?.ignoreUndefined ?? false;
44442
- this.forceIntegerToFloat = options?.forceIntegerToFloat ?? false;
44443
- this.pos = 0;
44444
- this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
44445
- this.bytes = new Uint8Array(this.view.buffer);
44446
- }
44447
- clone() {
44448
- return new _Encoder({
44449
- extensionCodec: this.extensionCodec,
44450
- context: this.context,
44451
- useBigInt64: this.useBigInt64,
44452
- maxDepth: this.maxDepth,
44453
- initialBufferSize: this.initialBufferSize,
44454
- sortKeys: this.sortKeys,
44455
- forceFloat32: this.forceFloat32,
44456
- ignoreUndefined: this.ignoreUndefined,
44457
- forceIntegerToFloat: this.forceIntegerToFloat
44458
- });
44459
- }
44460
- reinitializeState() {
44461
- this.pos = 0;
44462
- }
44463
- /**
44464
- * 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}.
44465
- *
44466
- * @returns Encodes the object and returns a shared reference the encoder's internal buffer.
44467
- */
44468
- encodeSharedRef(object2) {
44469
- if (this.entered) {
44470
- const instance = this.clone();
44471
- return instance.encodeSharedRef(object2);
44472
- }
44473
- try {
44474
- this.entered = true;
44475
- this.reinitializeState();
44476
- this.doEncode(object2, 1);
44477
- return this.bytes.subarray(0, this.pos);
44478
- } finally {
44479
- this.entered = false;
44480
- }
44481
- }
44482
- /**
44483
- * @returns Encodes the object and returns a copy of the encoder's internal buffer.
44484
- */
44485
- encode(object2) {
44486
- if (this.entered) {
44487
- const instance = this.clone();
44488
- return instance.encode(object2);
44489
- }
44490
- try {
44491
- this.entered = true;
44492
- this.reinitializeState();
44493
- this.doEncode(object2, 1);
44494
- return this.bytes.slice(0, this.pos);
44495
- } finally {
44496
- this.entered = false;
44497
- }
44498
- }
44499
- doEncode(object2, depth) {
44500
- if (depth > this.maxDepth) {
44501
- throw new Error(`Too deep objects in depth ${depth}`);
44502
- }
44503
- if (object2 == null) {
44504
- this.encodeNil();
44505
- } else if (typeof object2 === "boolean") {
44506
- this.encodeBoolean(object2);
44507
- } else if (typeof object2 === "number") {
44508
- if (!this.forceIntegerToFloat) {
44509
- this.encodeNumber(object2);
44510
- } else {
44511
- this.encodeNumberAsFloat(object2);
44512
- }
44513
- } else if (typeof object2 === "string") {
44514
- this.encodeString(object2);
44515
- } else if (this.useBigInt64 && typeof object2 === "bigint") {
44516
- this.encodeBigInt64(object2);
44517
- } else {
44518
- this.encodeObject(object2, depth);
44519
- }
44520
- }
44521
- ensureBufferSizeToWrite(sizeToWrite) {
44522
- const requiredSize = this.pos + sizeToWrite;
44523
- if (this.view.byteLength < requiredSize) {
44524
- this.resizeBuffer(requiredSize * 2);
44525
- }
44526
- }
44527
- resizeBuffer(newSize) {
44528
- const newBuffer = new ArrayBuffer(newSize);
44529
- const newBytes = new Uint8Array(newBuffer);
44530
- const newView = new DataView(newBuffer);
44531
- newBytes.set(this.bytes);
44532
- this.view = newView;
44533
- this.bytes = newBytes;
44534
- }
44535
- encodeNil() {
44536
- this.writeU8(192);
44537
- }
44538
- encodeBoolean(object2) {
44539
- if (object2 === false) {
44540
- this.writeU8(194);
44541
- } else {
44542
- this.writeU8(195);
44543
- }
44544
- }
44545
- encodeNumber(object2) {
44546
- if (!this.forceIntegerToFloat && Number.isSafeInteger(object2)) {
44547
- if (object2 >= 0) {
44548
- if (object2 < 128) {
44549
- this.writeU8(object2);
44550
- } else if (object2 < 256) {
44551
- this.writeU8(204);
44552
- this.writeU8(object2);
44553
- } else if (object2 < 65536) {
44554
- this.writeU8(205);
44555
- this.writeU16(object2);
44556
- } else if (object2 < 4294967296) {
44557
- this.writeU8(206);
44558
- this.writeU32(object2);
44559
- } else if (!this.useBigInt64) {
44560
- this.writeU8(207);
44561
- this.writeU64(object2);
44562
- } else {
44563
- this.encodeNumberAsFloat(object2);
44564
- }
44565
- } else {
44566
- if (object2 >= -32) {
44567
- this.writeU8(224 | object2 + 32);
44568
- } else if (object2 >= -128) {
44569
- this.writeU8(208);
44570
- this.writeI8(object2);
44571
- } else if (object2 >= -32768) {
44572
- this.writeU8(209);
44573
- this.writeI16(object2);
44574
- } else if (object2 >= -2147483648) {
44575
- this.writeU8(210);
44576
- this.writeI32(object2);
44577
- } else if (!this.useBigInt64) {
44578
- this.writeU8(211);
44579
- this.writeI64(object2);
44580
- } else {
44581
- this.encodeNumberAsFloat(object2);
44582
- }
44583
- }
44584
- } else {
44585
- this.encodeNumberAsFloat(object2);
44586
- }
44587
- }
44588
- encodeNumberAsFloat(object2) {
44589
- if (this.forceFloat32) {
44590
- this.writeU8(202);
44591
- this.writeF32(object2);
44592
- } else {
44593
- this.writeU8(203);
44594
- this.writeF64(object2);
44595
- }
44596
- }
44597
- encodeBigInt64(object2) {
44598
- if (object2 >= BigInt(0)) {
44599
- this.writeU8(207);
44600
- this.writeBigUint64(object2);
44601
- } else {
44602
- this.writeU8(211);
44603
- this.writeBigInt64(object2);
44604
- }
44605
- }
44606
- writeStringHeader(byteLength) {
44607
- if (byteLength < 32) {
44608
- this.writeU8(160 + byteLength);
44609
- } else if (byteLength < 256) {
44610
- this.writeU8(217);
44611
- this.writeU8(byteLength);
44612
- } else if (byteLength < 65536) {
44613
- this.writeU8(218);
44614
- this.writeU16(byteLength);
44615
- } else if (byteLength < 4294967296) {
44616
- this.writeU8(219);
44617
- this.writeU32(byteLength);
44618
- } else {
44619
- throw new Error(`Too long string: ${byteLength} bytes in UTF-8`);
44620
- }
44621
- }
44622
- encodeString(object2) {
44623
- const maxHeaderSize = 1 + 4;
44624
- const byteLength = utf8Count(object2);
44625
- this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
44626
- this.writeStringHeader(byteLength);
44627
- utf8Encode(object2, this.bytes, this.pos);
44628
- this.pos += byteLength;
44629
- }
44630
- encodeObject(object2, depth) {
44631
- const ext = this.extensionCodec.tryToEncode(object2, this.context);
44632
- if (ext != null) {
44633
- this.encodeExtension(ext);
44634
- } else if (Array.isArray(object2)) {
44635
- this.encodeArray(object2, depth);
44636
- } else if (ArrayBuffer.isView(object2)) {
44637
- this.encodeBinary(object2);
44638
- } else if (typeof object2 === "object") {
44639
- this.encodeMap(object2, depth);
44640
- } else {
44641
- throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(object2)}`);
44642
- }
44643
- }
44644
- encodeBinary(object2) {
44645
- const size = object2.byteLength;
44646
- if (size < 256) {
44647
- this.writeU8(196);
44648
- this.writeU8(size);
44649
- } else if (size < 65536) {
44650
- this.writeU8(197);
44651
- this.writeU16(size);
44652
- } else if (size < 4294967296) {
44653
- this.writeU8(198);
44654
- this.writeU32(size);
44655
- } else {
44656
- throw new Error(`Too large binary: ${size}`);
44657
- }
44658
- const bytes = ensureUint8Array(object2);
44659
- this.writeU8a(bytes);
44660
- }
44661
- encodeArray(object2, depth) {
44662
- const size = object2.length;
44663
- if (size < 16) {
44664
- this.writeU8(144 + size);
44665
- } else if (size < 65536) {
44666
- this.writeU8(220);
44667
- this.writeU16(size);
44668
- } else if (size < 4294967296) {
44669
- this.writeU8(221);
44670
- this.writeU32(size);
44671
- } else {
44672
- throw new Error(`Too large array: ${size}`);
44673
- }
44674
- for (const item of object2) {
44675
- this.doEncode(item, depth + 1);
44676
- }
44677
- }
44678
- countWithoutUndefined(object2, keys) {
44679
- let count = 0;
44680
- for (const key of keys) {
44681
- if (object2[key] !== void 0) {
44682
- count++;
44683
- }
44684
- }
44685
- return count;
44686
- }
44687
- encodeMap(object2, depth) {
44688
- const keys = Object.keys(object2);
44689
- if (this.sortKeys) {
44690
- keys.sort();
44691
- }
44692
- const size = this.ignoreUndefined ? this.countWithoutUndefined(object2, keys) : keys.length;
44693
- if (size < 16) {
44694
- this.writeU8(128 + size);
44695
- } else if (size < 65536) {
44696
- this.writeU8(222);
44697
- this.writeU16(size);
44698
- } else if (size < 4294967296) {
44699
- this.writeU8(223);
44700
- this.writeU32(size);
44701
- } else {
44702
- throw new Error(`Too large map object: ${size}`);
44703
- }
44704
- for (const key of keys) {
44705
- const value = object2[key];
44706
- if (!(this.ignoreUndefined && value === void 0)) {
44707
- this.encodeString(key);
44708
- this.doEncode(value, depth + 1);
44709
- }
44710
- }
44711
- }
44712
- encodeExtension(ext) {
44713
- if (typeof ext.data === "function") {
44714
- const data = ext.data(this.pos + 6);
44715
- const size2 = data.length;
44716
- if (size2 >= 4294967296) {
44717
- throw new Error(`Too large extension object: ${size2}`);
44718
- }
44719
- this.writeU8(201);
44720
- this.writeU32(size2);
44721
- this.writeI8(ext.type);
44722
- this.writeU8a(data);
44723
- return;
44724
- }
44725
- const size = ext.data.length;
44726
- if (size === 1) {
44727
- this.writeU8(212);
44728
- } else if (size === 2) {
44729
- this.writeU8(213);
44730
- } else if (size === 4) {
44731
- this.writeU8(214);
44732
- } else if (size === 8) {
44733
- this.writeU8(215);
44734
- } else if (size === 16) {
44735
- this.writeU8(216);
44736
- } else if (size < 256) {
44737
- this.writeU8(199);
44738
- this.writeU8(size);
44739
- } else if (size < 65536) {
44740
- this.writeU8(200);
44741
- this.writeU16(size);
44742
- } else if (size < 4294967296) {
44743
- this.writeU8(201);
44744
- this.writeU32(size);
44745
- } else {
44746
- throw new Error(`Too large extension object: ${size}`);
44747
- }
44748
- this.writeI8(ext.type);
44749
- this.writeU8a(ext.data);
44750
- }
44751
- writeU8(value) {
44752
- this.ensureBufferSizeToWrite(1);
44753
- this.view.setUint8(this.pos, value);
44754
- this.pos++;
44755
- }
44756
- writeU8a(values) {
44757
- const size = values.length;
44758
- this.ensureBufferSizeToWrite(size);
44759
- this.bytes.set(values, this.pos);
44760
- this.pos += size;
44761
- }
44762
- writeI8(value) {
44763
- this.ensureBufferSizeToWrite(1);
44764
- this.view.setInt8(this.pos, value);
44765
- this.pos++;
44766
- }
44767
- writeU16(value) {
44768
- this.ensureBufferSizeToWrite(2);
44769
- this.view.setUint16(this.pos, value);
44770
- this.pos += 2;
44771
- }
44772
- writeI16(value) {
44773
- this.ensureBufferSizeToWrite(2);
44774
- this.view.setInt16(this.pos, value);
44775
- this.pos += 2;
44776
- }
44777
- writeU32(value) {
44778
- this.ensureBufferSizeToWrite(4);
44779
- this.view.setUint32(this.pos, value);
44780
- this.pos += 4;
44781
- }
44782
- writeI32(value) {
44783
- this.ensureBufferSizeToWrite(4);
44784
- this.view.setInt32(this.pos, value);
44785
- this.pos += 4;
44786
- }
44787
- writeF32(value) {
44788
- this.ensureBufferSizeToWrite(4);
44789
- this.view.setFloat32(this.pos, value);
44790
- this.pos += 4;
44791
- }
44792
- writeF64(value) {
44793
- this.ensureBufferSizeToWrite(8);
44794
- this.view.setFloat64(this.pos, value);
44795
- this.pos += 8;
44796
- }
44797
- writeU64(value) {
44798
- this.ensureBufferSizeToWrite(8);
44799
- setUint64(this.view, this.pos, value);
44800
- this.pos += 8;
44801
- }
44802
- writeI64(value) {
44803
- this.ensureBufferSizeToWrite(8);
44804
- setInt64(this.view, this.pos, value);
44805
- this.pos += 8;
44806
- }
44807
- writeBigUint64(value) {
44808
- this.ensureBufferSizeToWrite(8);
44809
- this.view.setBigUint64(this.pos, value);
44810
- this.pos += 8;
44811
- }
44812
- writeBigInt64(value) {
44813
- this.ensureBufferSizeToWrite(8);
44814
- this.view.setBigInt64(this.pos, value);
44815
- this.pos += 8;
44816
- }
44817
- };
44818
-
44819
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/utils/prettyByte.mjs
44820
- function prettyByte(byte) {
44821
- return `${byte < 0 ? "-" : ""}0x${Math.abs(byte).toString(16).padStart(2, "0")}`;
44822
- }
44823
-
44824
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/CachedKeyDecoder.mjs
44825
- var DEFAULT_MAX_KEY_LENGTH = 16;
44826
- var DEFAULT_MAX_LENGTH_PER_KEY = 16;
44827
- var CachedKeyDecoder = class {
44828
- hit = 0;
44829
- miss = 0;
44830
- caches;
44831
- maxKeyLength;
44832
- maxLengthPerKey;
44833
- constructor(maxKeyLength = DEFAULT_MAX_KEY_LENGTH, maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY) {
44834
- this.maxKeyLength = maxKeyLength;
44835
- this.maxLengthPerKey = maxLengthPerKey;
44836
- this.caches = [];
44837
- for (let i = 0; i < this.maxKeyLength; i++) {
44838
- this.caches.push([]);
44839
- }
44840
- }
44841
- canBeCached(byteLength) {
44842
- return byteLength > 0 && byteLength <= this.maxKeyLength;
44843
- }
44844
- find(bytes, inputOffset, byteLength) {
44845
- const records = this.caches[byteLength - 1];
44846
- FIND_CHUNK: for (const record of records) {
44847
- const recordBytes = record.bytes;
44848
- for (let j = 0; j < byteLength; j++) {
44849
- if (recordBytes[j] !== bytes[inputOffset + j]) {
44850
- continue FIND_CHUNK;
44851
- }
44852
- }
44853
- return record.str;
44854
- }
44855
- return null;
44856
- }
44857
- store(bytes, value) {
44858
- const records = this.caches[bytes.length - 1];
44859
- const record = { bytes, str: value };
44860
- if (records.length >= this.maxLengthPerKey) {
44861
- records[Math.random() * records.length | 0] = record;
44862
- } else {
44863
- records.push(record);
44864
- }
44865
- }
44866
- decode(bytes, inputOffset, byteLength) {
44867
- const cachedValue = this.find(bytes, inputOffset, byteLength);
44868
- if (cachedValue != null) {
44869
- this.hit++;
44870
- return cachedValue;
44871
- }
44872
- this.miss++;
44873
- const str = utf8DecodeJs(bytes, inputOffset, byteLength);
44874
- const slicedCopyOfBytes = Uint8Array.prototype.slice.call(bytes, inputOffset, inputOffset + byteLength);
44875
- this.store(slicedCopyOfBytes, str);
44876
- return str;
44877
- }
44878
- };
44879
-
44880
- // node_modules/.pnpm/@msgpack+msgpack@3.1.3/node_modules/@msgpack/msgpack/dist.esm/Decoder.mjs
44881
- var STATE_ARRAY = "array";
44882
- var STATE_MAP_KEY = "map_key";
44883
- var STATE_MAP_VALUE = "map_value";
44884
- var mapKeyConverter = (key) => {
44885
- if (typeof key === "string" || typeof key === "number") {
44886
- return key;
44887
- }
44888
- throw new DecodeError("The type of key must be string or number but " + typeof key);
44889
- };
44890
- var StackPool = class {
44891
- stack = [];
44892
- stackHeadPosition = -1;
44893
- get length() {
44894
- return this.stackHeadPosition + 1;
44895
- }
44896
- top() {
44897
- return this.stack[this.stackHeadPosition];
44898
- }
44899
- pushArrayState(size) {
44900
- const state = this.getUninitializedStateFromPool();
44901
- state.type = STATE_ARRAY;
44902
- state.position = 0;
44903
- state.size = size;
44904
- state.array = new Array(size);
44905
- }
44906
- pushMapState(size) {
44907
- const state = this.getUninitializedStateFromPool();
44908
- state.type = STATE_MAP_KEY;
44909
- state.readCount = 0;
44910
- state.size = size;
44911
- state.map = {};
44912
- }
44913
- getUninitializedStateFromPool() {
44914
- this.stackHeadPosition++;
44915
- if (this.stackHeadPosition === this.stack.length) {
44916
- const partialState = {
44917
- type: void 0,
44918
- size: 0,
44919
- array: void 0,
44920
- position: 0,
44921
- readCount: 0,
44922
- map: void 0,
44923
- key: null
44924
- };
44925
- this.stack.push(partialState);
44926
- }
44927
- return this.stack[this.stackHeadPosition];
44928
- }
44929
- release(state) {
44930
- const topStackState = this.stack[this.stackHeadPosition];
44931
- if (topStackState !== state) {
44932
- throw new Error("Invalid stack state. Released state is not on top of the stack.");
44933
- }
44934
- if (state.type === STATE_ARRAY) {
44935
- const partialState = state;
44936
- partialState.size = 0;
44937
- partialState.array = void 0;
44938
- partialState.position = 0;
44939
- partialState.type = void 0;
44940
- }
44941
- if (state.type === STATE_MAP_KEY || state.type === STATE_MAP_VALUE) {
44942
- const partialState = state;
44943
- partialState.size = 0;
44944
- partialState.map = void 0;
44945
- partialState.readCount = 0;
44946
- partialState.type = void 0;
44947
- }
44948
- this.stackHeadPosition--;
44949
- }
44950
- reset() {
44951
- this.stack.length = 0;
44952
- this.stackHeadPosition = -1;
44953
- }
44954
- };
44955
- var HEAD_BYTE_REQUIRED = -1;
44956
- var EMPTY_VIEW = new DataView(new ArrayBuffer(0));
44957
- var EMPTY_BYTES = new Uint8Array(EMPTY_VIEW.buffer);
44958
- try {
44959
- EMPTY_VIEW.getInt8(0);
44960
- } catch (e) {
44961
- if (!(e instanceof RangeError)) {
44962
- throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
44963
- }
44964
- }
44965
- var MORE_DATA = new RangeError("Insufficient data");
44966
- var sharedCachedKeyDecoder = new CachedKeyDecoder();
44967
- var Decoder = class _Decoder {
44968
- extensionCodec;
44969
- context;
44970
- useBigInt64;
44971
- rawStrings;
44972
- maxStrLength;
44973
- maxBinLength;
44974
- maxArrayLength;
44975
- maxMapLength;
44976
- maxExtLength;
44977
- keyDecoder;
44978
- mapKeyConverter;
44979
- totalPos = 0;
44980
- pos = 0;
44981
- view = EMPTY_VIEW;
44982
- bytes = EMPTY_BYTES;
44983
- headByte = HEAD_BYTE_REQUIRED;
44984
- stack = new StackPool();
44985
- entered = false;
44986
- constructor(options) {
44987
- this.extensionCodec = options?.extensionCodec ?? ExtensionCodec.defaultCodec;
44988
- this.context = options?.context;
44989
- this.useBigInt64 = options?.useBigInt64 ?? false;
44990
- this.rawStrings = options?.rawStrings ?? false;
44991
- this.maxStrLength = options?.maxStrLength ?? UINT32_MAX;
44992
- this.maxBinLength = options?.maxBinLength ?? UINT32_MAX;
44993
- this.maxArrayLength = options?.maxArrayLength ?? UINT32_MAX;
44994
- this.maxMapLength = options?.maxMapLength ?? UINT32_MAX;
44995
- this.maxExtLength = options?.maxExtLength ?? UINT32_MAX;
44996
- this.keyDecoder = options?.keyDecoder !== void 0 ? options.keyDecoder : sharedCachedKeyDecoder;
44997
- this.mapKeyConverter = options?.mapKeyConverter ?? mapKeyConverter;
44998
- }
44999
- clone() {
45000
- return new _Decoder({
45001
- extensionCodec: this.extensionCodec,
45002
- context: this.context,
45003
- useBigInt64: this.useBigInt64,
45004
- rawStrings: this.rawStrings,
45005
- maxStrLength: this.maxStrLength,
45006
- maxBinLength: this.maxBinLength,
45007
- maxArrayLength: this.maxArrayLength,
45008
- maxMapLength: this.maxMapLength,
45009
- maxExtLength: this.maxExtLength,
45010
- keyDecoder: this.keyDecoder
45011
- });
45012
- }
45013
- reinitializeState() {
45014
- this.totalPos = 0;
45015
- this.headByte = HEAD_BYTE_REQUIRED;
45016
- this.stack.reset();
45017
- }
45018
- setBuffer(buffer) {
45019
- const bytes = ensureUint8Array(buffer);
45020
- this.bytes = bytes;
45021
- this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
45022
- this.pos = 0;
45023
- }
45024
- appendBuffer(buffer) {
45025
- if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining(1)) {
45026
- this.setBuffer(buffer);
45027
- } else {
45028
- const remainingData = this.bytes.subarray(this.pos);
45029
- const newData = ensureUint8Array(buffer);
45030
- const newBuffer = new Uint8Array(remainingData.length + newData.length);
45031
- newBuffer.set(remainingData);
45032
- newBuffer.set(newData, remainingData.length);
45033
- this.setBuffer(newBuffer);
45034
- }
45035
- }
45036
- hasRemaining(size) {
45037
- return this.view.byteLength - this.pos >= size;
45038
- }
45039
- createExtraByteError(posToShow) {
45040
- const { view, pos } = this;
45041
- return new RangeError(`Extra ${view.byteLength - pos} of ${view.byteLength} byte(s) found at buffer[${posToShow}]`);
45042
- }
45043
- /**
45044
- * @throws {@link DecodeError}
45045
- * @throws {@link RangeError}
45046
- */
45047
- decode(buffer) {
45048
- if (this.entered) {
45049
- const instance = this.clone();
45050
- return instance.decode(buffer);
45051
- }
45052
- try {
45053
- this.entered = true;
45054
- this.reinitializeState();
45055
- this.setBuffer(buffer);
45056
- const object2 = this.doDecodeSync();
45057
- if (this.hasRemaining(1)) {
45058
- throw this.createExtraByteError(this.pos);
45059
- }
45060
- return object2;
45061
- } finally {
45062
- this.entered = false;
45063
- }
45064
- }
45065
- *decodeMulti(buffer) {
45066
- if (this.entered) {
45067
- const instance = this.clone();
45068
- yield* instance.decodeMulti(buffer);
45069
- return;
45070
- }
45071
- try {
45072
- this.entered = true;
45073
- this.reinitializeState();
45074
- this.setBuffer(buffer);
45075
- while (this.hasRemaining(1)) {
45076
- yield this.doDecodeSync();
45077
- }
45078
- } finally {
45079
- this.entered = false;
45080
- }
45081
- }
45082
- async decodeAsync(stream) {
45083
- if (this.entered) {
45084
- const instance = this.clone();
45085
- return instance.decodeAsync(stream);
45086
- }
45087
- try {
45088
- this.entered = true;
45089
- let decoded = false;
45090
- let object2;
45091
- for await (const buffer of stream) {
45092
- if (decoded) {
45093
- this.entered = false;
45094
- throw this.createExtraByteError(this.totalPos);
45095
- }
45096
- this.appendBuffer(buffer);
45097
- try {
45098
- object2 = this.doDecodeSync();
45099
- decoded = true;
45100
- } catch (e) {
45101
- if (!(e instanceof RangeError)) {
45102
- throw e;
45103
- }
45104
- }
45105
- this.totalPos += this.pos;
45106
- }
45107
- if (decoded) {
45108
- if (this.hasRemaining(1)) {
45109
- throw this.createExtraByteError(this.totalPos);
45110
- }
45111
- return object2;
45112
- }
45113
- const { headByte, pos, totalPos } = this;
45114
- throw new RangeError(`Insufficient data in parsing ${prettyByte(headByte)} at ${totalPos} (${pos} in the current buffer)`);
45115
- } finally {
45116
- this.entered = false;
45117
- }
45118
- }
45119
- decodeArrayStream(stream) {
45120
- return this.decodeMultiAsync(stream, true);
45121
- }
45122
- decodeStream(stream) {
45123
- return this.decodeMultiAsync(stream, false);
45124
- }
45125
- async *decodeMultiAsync(stream, isArray) {
45126
- if (this.entered) {
45127
- const instance = this.clone();
45128
- yield* instance.decodeMultiAsync(stream, isArray);
45129
- return;
45130
- }
45131
- try {
45132
- this.entered = true;
45133
- let isArrayHeaderRequired = isArray;
45134
- let arrayItemsLeft = -1;
45135
- for await (const buffer of stream) {
45136
- if (isArray && arrayItemsLeft === 0) {
45137
- throw this.createExtraByteError(this.totalPos);
45138
- }
45139
- this.appendBuffer(buffer);
45140
- if (isArrayHeaderRequired) {
45141
- arrayItemsLeft = this.readArraySize();
45142
- isArrayHeaderRequired = false;
45143
- this.complete();
45144
- }
45145
- try {
45146
- while (true) {
45147
- yield this.doDecodeSync();
45148
- if (--arrayItemsLeft === 0) {
45149
- break;
45150
- }
45151
- }
45152
- } catch (e) {
45153
- if (!(e instanceof RangeError)) {
45154
- throw e;
45155
- }
45156
- }
45157
- this.totalPos += this.pos;
45158
- }
45159
- } finally {
45160
- this.entered = false;
45161
- }
45162
- }
45163
- doDecodeSync() {
45164
- DECODE: while (true) {
45165
- const headByte = this.readHeadByte();
45166
- let object2;
45167
- if (headByte >= 224) {
45168
- object2 = headByte - 256;
45169
- } else if (headByte < 192) {
45170
- if (headByte < 128) {
45171
- object2 = headByte;
45172
- } else if (headByte < 144) {
45173
- const size = headByte - 128;
45174
- if (size !== 0) {
45175
- this.pushMapState(size);
45176
- this.complete();
45177
- continue DECODE;
45178
- } else {
45179
- object2 = {};
45180
- }
45181
- } else if (headByte < 160) {
45182
- const size = headByte - 144;
45183
- if (size !== 0) {
45184
- this.pushArrayState(size);
45185
- this.complete();
45186
- continue DECODE;
45187
- } else {
45188
- object2 = [];
45189
- }
45190
- } else {
45191
- const byteLength = headByte - 160;
45192
- object2 = this.decodeString(byteLength, 0);
45193
- }
45194
- } else if (headByte === 192) {
45195
- object2 = null;
45196
- } else if (headByte === 194) {
45197
- object2 = false;
45198
- } else if (headByte === 195) {
45199
- object2 = true;
45200
- } else if (headByte === 202) {
45201
- object2 = this.readF32();
45202
- } else if (headByte === 203) {
45203
- object2 = this.readF64();
45204
- } else if (headByte === 204) {
45205
- object2 = this.readU8();
45206
- } else if (headByte === 205) {
45207
- object2 = this.readU16();
45208
- } else if (headByte === 206) {
45209
- object2 = this.readU32();
45210
- } else if (headByte === 207) {
45211
- if (this.useBigInt64) {
45212
- object2 = this.readU64AsBigInt();
45213
- } else {
45214
- object2 = this.readU64();
45215
- }
45216
- } else if (headByte === 208) {
45217
- object2 = this.readI8();
45218
- } else if (headByte === 209) {
45219
- object2 = this.readI16();
45220
- } else if (headByte === 210) {
45221
- object2 = this.readI32();
45222
- } else if (headByte === 211) {
45223
- if (this.useBigInt64) {
45224
- object2 = this.readI64AsBigInt();
45225
- } else {
45226
- object2 = this.readI64();
45227
- }
45228
- } else if (headByte === 217) {
45229
- const byteLength = this.lookU8();
45230
- object2 = this.decodeString(byteLength, 1);
45231
- } else if (headByte === 218) {
45232
- const byteLength = this.lookU16();
45233
- object2 = this.decodeString(byteLength, 2);
45234
- } else if (headByte === 219) {
45235
- const byteLength = this.lookU32();
45236
- object2 = this.decodeString(byteLength, 4);
45237
- } else if (headByte === 220) {
45238
- const size = this.readU16();
45239
- if (size !== 0) {
45240
- this.pushArrayState(size);
45241
- this.complete();
45242
- continue DECODE;
45243
- } else {
45244
- object2 = [];
45245
- }
45246
- } else if (headByte === 221) {
45247
- const size = this.readU32();
45248
- if (size !== 0) {
45249
- this.pushArrayState(size);
45250
- this.complete();
45251
- continue DECODE;
45252
- } else {
45253
- object2 = [];
45254
- }
45255
- } else if (headByte === 222) {
45256
- const size = this.readU16();
45257
- if (size !== 0) {
45258
- this.pushMapState(size);
45259
- this.complete();
45260
- continue DECODE;
45261
- } else {
45262
- object2 = {};
45263
- }
45264
- } else if (headByte === 223) {
45265
- const size = this.readU32();
45266
- if (size !== 0) {
45267
- this.pushMapState(size);
45268
- this.complete();
45269
- continue DECODE;
45270
- } else {
45271
- object2 = {};
45272
- }
45273
- } else if (headByte === 196) {
45274
- const size = this.lookU8();
45275
- object2 = this.decodeBinary(size, 1);
45276
- } else if (headByte === 197) {
45277
- const size = this.lookU16();
45278
- object2 = this.decodeBinary(size, 2);
45279
- } else if (headByte === 198) {
45280
- const size = this.lookU32();
45281
- object2 = this.decodeBinary(size, 4);
45282
- } else if (headByte === 212) {
45283
- object2 = this.decodeExtension(1, 0);
45284
- } else if (headByte === 213) {
45285
- object2 = this.decodeExtension(2, 0);
45286
- } else if (headByte === 214) {
45287
- object2 = this.decodeExtension(4, 0);
45288
- } else if (headByte === 215) {
45289
- object2 = this.decodeExtension(8, 0);
45290
- } else if (headByte === 216) {
45291
- object2 = this.decodeExtension(16, 0);
45292
- } else if (headByte === 199) {
45293
- const size = this.lookU8();
45294
- object2 = this.decodeExtension(size, 1);
45295
- } else if (headByte === 200) {
45296
- const size = this.lookU16();
45297
- object2 = this.decodeExtension(size, 2);
45298
- } else if (headByte === 201) {
45299
- const size = this.lookU32();
45300
- object2 = this.decodeExtension(size, 4);
45301
- } else {
45302
- throw new DecodeError(`Unrecognized type byte: ${prettyByte(headByte)}`);
45303
- }
45304
- this.complete();
45305
- const stack = this.stack;
45306
- while (stack.length > 0) {
45307
- const state = stack.top();
45308
- if (state.type === STATE_ARRAY) {
45309
- state.array[state.position] = object2;
45310
- state.position++;
45311
- if (state.position === state.size) {
45312
- object2 = state.array;
45313
- stack.release(state);
45314
- } else {
45315
- continue DECODE;
45316
- }
45317
- } else if (state.type === STATE_MAP_KEY) {
45318
- if (object2 === "__proto__") {
45319
- throw new DecodeError("The key __proto__ is not allowed");
45320
- }
45321
- state.key = this.mapKeyConverter(object2);
45322
- state.type = STATE_MAP_VALUE;
45323
- continue DECODE;
45324
- } else {
45325
- state.map[state.key] = object2;
45326
- state.readCount++;
45327
- if (state.readCount === state.size) {
45328
- object2 = state.map;
45329
- stack.release(state);
45330
- } else {
45331
- state.key = null;
45332
- state.type = STATE_MAP_KEY;
45333
- continue DECODE;
45334
- }
45335
- }
45336
- }
45337
- return object2;
45338
- }
45339
- }
45340
- readHeadByte() {
45341
- if (this.headByte === HEAD_BYTE_REQUIRED) {
45342
- this.headByte = this.readU8();
45343
- }
45344
- return this.headByte;
45345
- }
45346
- complete() {
45347
- this.headByte = HEAD_BYTE_REQUIRED;
45348
- }
45349
- readArraySize() {
45350
- const headByte = this.readHeadByte();
45351
- switch (headByte) {
45352
- case 220:
45353
- return this.readU16();
45354
- case 221:
45355
- return this.readU32();
45356
- default: {
45357
- if (headByte < 160) {
45358
- return headByte - 144;
45359
- } else {
45360
- throw new DecodeError(`Unrecognized array type byte: ${prettyByte(headByte)}`);
45361
- }
45362
- }
45363
- }
45364
- }
45365
- pushMapState(size) {
45366
- if (size > this.maxMapLength) {
45367
- throw new DecodeError(`Max length exceeded: map length (${size}) > maxMapLengthLength (${this.maxMapLength})`);
45368
- }
45369
- this.stack.pushMapState(size);
45370
- }
45371
- pushArrayState(size) {
45372
- if (size > this.maxArrayLength) {
45373
- throw new DecodeError(`Max length exceeded: array length (${size}) > maxArrayLength (${this.maxArrayLength})`);
45374
- }
45375
- this.stack.pushArrayState(size);
45376
- }
45377
- decodeString(byteLength, headerOffset) {
45378
- if (!this.rawStrings || this.stateIsMapKey()) {
45379
- return this.decodeUtf8String(byteLength, headerOffset);
45380
- }
45381
- return this.decodeBinary(byteLength, headerOffset);
45382
- }
45383
- /**
45384
- * @throws {@link RangeError}
45385
- */
45386
- decodeUtf8String(byteLength, headerOffset) {
45387
- if (byteLength > this.maxStrLength) {
45388
- throw new DecodeError(`Max length exceeded: UTF-8 byte length (${byteLength}) > maxStrLength (${this.maxStrLength})`);
45389
- }
45390
- if (this.bytes.byteLength < this.pos + headerOffset + byteLength) {
45391
- throw MORE_DATA;
45392
- }
45393
- const offset = this.pos + headerOffset;
45394
- let object2;
45395
- if (this.stateIsMapKey() && this.keyDecoder?.canBeCached(byteLength)) {
45396
- object2 = this.keyDecoder.decode(this.bytes, offset, byteLength);
45397
- } else {
45398
- object2 = utf8Decode(this.bytes, offset, byteLength);
45399
- }
45400
- this.pos += headerOffset + byteLength;
45401
- return object2;
45402
- }
45403
- stateIsMapKey() {
45404
- if (this.stack.length > 0) {
45405
- const state = this.stack.top();
45406
- return state.type === STATE_MAP_KEY;
45407
- }
45408
- return false;
45409
- }
45410
- /**
45411
- * @throws {@link RangeError}
45412
- */
45413
- decodeBinary(byteLength, headOffset) {
45414
- if (byteLength > this.maxBinLength) {
45415
- throw new DecodeError(`Max length exceeded: bin length (${byteLength}) > maxBinLength (${this.maxBinLength})`);
45416
- }
45417
- if (!this.hasRemaining(byteLength + headOffset)) {
45418
- throw MORE_DATA;
45419
- }
45420
- const offset = this.pos + headOffset;
45421
- const object2 = this.bytes.subarray(offset, offset + byteLength);
45422
- this.pos += headOffset + byteLength;
45423
- return object2;
45424
- }
45425
- decodeExtension(size, headOffset) {
45426
- if (size > this.maxExtLength) {
45427
- throw new DecodeError(`Max length exceeded: ext length (${size}) > maxExtLength (${this.maxExtLength})`);
45428
- }
45429
- const extType = this.view.getInt8(this.pos + headOffset);
45430
- const data = this.decodeBinary(
45431
- size,
45432
- headOffset + 1
45433
- /* extType */
45434
- );
45435
- return this.extensionCodec.decode(data, extType, this.context);
45436
- }
45437
- lookU8() {
45438
- return this.view.getUint8(this.pos);
45439
- }
45440
- lookU16() {
45441
- return this.view.getUint16(this.pos);
45442
- }
45443
- lookU32() {
45444
- return this.view.getUint32(this.pos);
45445
- }
45446
- readU8() {
45447
- const value = this.view.getUint8(this.pos);
45448
- this.pos++;
45449
- return value;
45450
- }
45451
- readI8() {
45452
- const value = this.view.getInt8(this.pos);
45453
- this.pos++;
45454
- return value;
45455
- }
45456
- readU16() {
45457
- const value = this.view.getUint16(this.pos);
45458
- this.pos += 2;
45459
- return value;
45460
- }
45461
- readI16() {
45462
- const value = this.view.getInt16(this.pos);
45463
- this.pos += 2;
45464
- return value;
45465
- }
45466
- readU32() {
45467
- const value = this.view.getUint32(this.pos);
45468
- this.pos += 4;
45469
- return value;
45470
- }
45471
- readI32() {
45472
- const value = this.view.getInt32(this.pos);
45473
- this.pos += 4;
45474
- return value;
45475
- }
45476
- readU64() {
45477
- const value = getUint64(this.view, this.pos);
45478
- this.pos += 8;
45479
- return value;
45480
- }
45481
- readI64() {
45482
- const value = getInt64(this.view, this.pos);
45483
- this.pos += 8;
45484
- return value;
45485
- }
45486
- readU64AsBigInt() {
45487
- const value = this.view.getBigUint64(this.pos);
45488
- this.pos += 8;
45489
- return value;
45490
- }
45491
- readI64AsBigInt() {
45492
- const value = this.view.getBigInt64(this.pos);
45493
- this.pos += 8;
45494
- return value;
45495
- }
45496
- readF32() {
45497
- const value = this.view.getFloat32(this.pos);
45498
- this.pos += 4;
45499
- return value;
45500
- }
45501
- readF64() {
45502
- const value = this.view.getFloat64(this.pos);
45503
- this.pos += 8;
45504
- return value;
45505
- }
45506
- };
45507
-
45508
- // src/vendor/titan/client.ts
45509
44078
  var SUBPROTOCOL = "v1.api.titan.ag";
45510
44079
  var UINT64_MAX = (1n << 64n) - 1n;
45511
44080
  function toBigInt(value) {
@@ -50900,7 +49469,10 @@ async function getTitanSwapIxsViaWebSocket(params, feeAccount) {
50900
49469
  const swapInstructions = bestRoute.instructions.map(deserializeTitanInstruction);
50901
49470
  const lutPubkeys = bestRoute.addressLookupTables.map((lutBytes) => new PublicKey(lutBytes));
50902
49471
  const addressLookupTableAddresses = await resolveLookupTables(connection, lutPubkeys);
50903
- const quoteResponse = buildSwapQuoteResult(bestRoute, swapMode);
49472
+ const quoteResponse = {
49473
+ ...buildSwapQuoteResult(bestRoute, swapMode),
49474
+ provider: "TITAN" /* TITAN */
49475
+ };
50904
49476
  return {
50905
49477
  swapInstructions,
50906
49478
  setupInstructions: [],
@@ -50977,7 +49549,10 @@ async function getTitanSwapIxsViaHttpProxy(params, feeAccount) {
50977
49549
  (b64) => new PublicKey(Buffer.from(b64, "base64"))
50978
49550
  );
50979
49551
  const addressLookupTableAddresses = await resolveLookupTables(connection, lutPubkeys);
50980
- const quoteResponse = buildSwapQuoteResult(bestRoute, swapMode);
49552
+ const quoteResponse = {
49553
+ ...buildSwapQuoteResult(bestRoute, swapMode),
49554
+ provider: "TITAN" /* TITAN */
49555
+ };
50981
49556
  return {
50982
49557
  swapInstructions,
50983
49558
  setupInstructions: [],
@@ -51028,7 +49603,10 @@ async function getTitanExactOutViaWebSocket(params) {
51028
49603
  if (!bestRoute) {
51029
49604
  throw new Error(`No Titan ExactOut routes found for ${inputMint} -> ${outputMint}`);
51030
49605
  }
51031
- const quoteResult = buildSwapQuoteResult(bestRoute, "ExactOut");
49606
+ const quoteResult = {
49607
+ ...buildSwapQuoteResult(bestRoute, "ExactOut"),
49608
+ provider: "TITAN" /* TITAN */
49609
+ };
51032
49610
  return {
51033
49611
  otherAmountThreshold: quoteResult.otherAmountThreshold,
51034
49612
  quoteResult
@@ -51069,7 +49647,8 @@ async function getTitanExactOutViaHttpProxy(params) {
51069
49647
  inAmount: String(data.inAmount),
51070
49648
  outAmount: String(data.outAmount),
51071
49649
  otherAmountThreshold: data.otherAmountThreshold,
51072
- slippageBps: data.slippageBps
49650
+ slippageBps: data.slippageBps,
49651
+ provider: "TITAN" /* TITAN */
51073
49652
  };
51074
49653
  return {
51075
49654
  otherAmountThreshold: data.otherAmountThreshold,
@@ -51283,7 +49862,8 @@ function mapJupiterQuoteToSwapQuoteResult(quote) {
51283
49862
  } : void 0,
51284
49863
  priceImpactPct: quote.priceImpactPct,
51285
49864
  contextSlot: quote.contextSlot,
51286
- timeTaken: quote.timeTaken
49865
+ timeTaken: quote.timeTaken,
49866
+ provider: "JUPITER" /* JUPITER */
51287
49867
  };
51288
49868
  }
51289
49869
 
@@ -52603,7 +51183,7 @@ function computeMaxLeverage(depositBank, borrowBank, opts) {
52603
51183
  ltv
52604
51184
  };
52605
51185
  }
52606
- function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank, depositOracleInfo, borrowOracleInfo, opts) {
51186
+ function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank, depositPriceUsd, borrowPriceUsd, opts) {
52607
51187
  const initialCollateral = toBigNumber(principal);
52608
51188
  const { maxLeverage } = computeMaxLeverage(depositBank, borrowBank, opts);
52609
51189
  let clampedLeverage = targetLeverage;
@@ -52618,7 +51198,7 @@ function computeLoopingParams(principal, targetLeverage, depositBank, borrowBank
52618
51198
  }
52619
51199
  const totalDepositAmount = initialCollateral.times(new BigNumber3(clampedLeverage));
52620
51200
  const additionalDepositAmount = totalDepositAmount.minus(initialCollateral);
52621
- const totalBorrowAmount = additionalDepositAmount.times(depositOracleInfo.priceWeighted.lowestPrice).div(borrowOracleInfo.priceWeighted.highestPrice);
51201
+ const totalBorrowAmount = additionalDepositAmount.times(new BigNumber3(depositPriceUsd)).div(new BigNumber3(borrowPriceUsd));
52622
51202
  return {
52623
51203
  totalBorrowAmount: totalBorrowAmount.decimalPlaces(
52624
51204
  borrowBank.mintDecimals,