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