@deriverse/kit 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  export declare class AutoBuffer {
3
4
  buffer: Buffer;
4
5
  offset_: number;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Address, Base64EncodedDataResponse } from '@solana/kit';
3
4
  export declare class AutoData {
4
5
  buffer: Buffer;
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ exports.Engine = exports.getPriceStep = void 0;
27
27
  const kit_1 = require("@solana/kit");
28
28
  const system_1 = require("@solana-program/system");
29
29
  const bs58_1 = require("bs58");
30
+ const buffer_1 = require("buffer");
30
31
  const types_1 = require("./types");
31
32
  const structure_models_1 = require("./structure_models");
32
33
  const instruction_models_1 = require("./instruction_models");
@@ -197,7 +198,7 @@ function getMultiplePerpOrders(data, firstEntry) {
197
198
  }
198
199
  function getLookupTableAddress(authority, slot) {
199
200
  return __awaiter(this, void 0, void 0, function* () {
200
- let buf = Buffer.alloc(8);
201
+ let buf = buffer_1.Buffer.alloc(8);
201
202
  buf.writeBigInt64LE(BigInt(slot), 0);
202
203
  const address = (yield (0, kit_1.getProgramDerivedAddress)({
203
204
  programAddress: ADDRESS_LOOKUP_TABLE_PROGRAM_ID,
@@ -247,7 +248,7 @@ class Engine {
247
248
  if (!log.startsWith("Program data: ")) {
248
249
  continue;
249
250
  }
250
- const buffer = Buffer.from((0, base64_arraybuffer_1.decode)(log.substring(14)));
251
+ const buffer = buffer_1.Buffer.from((0, base64_arraybuffer_1.decode)(log.substring(14)));
251
252
  switch (buffer[0]) {
252
253
  case logs_models_1.LogType.deposit: {
253
254
  if (buffer.length == logs_models_1.DepositReportModel.LENGTH) {
@@ -524,7 +525,7 @@ class Engine {
524
525
  }
525
526
  findAccountsByTag(tag, dataSlice) {
526
527
  return __awaiter(this, void 0, void 0, function* () {
527
- let tagBuf = Buffer.alloc(8);
528
+ let tagBuf = buffer_1.Buffer.alloc(8);
528
529
  tagBuf.writeUInt32LE(tag, 0);
529
530
  tagBuf.writeUInt32LE(this.version, 4);
530
531
  let accounts = yield this.rpc.getProgramAccounts(this.programId, {
@@ -569,7 +570,7 @@ class Engine {
569
570
  });
570
571
  const instrAccounts = yield this.findAccountsByTag(types_1.AccountType.INSTR, { offset: 8, length: 16 });
571
572
  instrAccounts.forEach((response) => {
572
- const buffer = Buffer.from((0, kit_1.getBase64Encoder)().encode(response.account.data[0]));
573
+ const buffer = buffer_1.Buffer.from((0, kit_1.getBase64Encoder)().encode(response.account.data[0]));
573
574
  let instrAccountHeaderModel = new structure_models_1.InstrAccountHeaderModel();
574
575
  instrAccountHeaderModel.id = buffer.readUint32LE(0);
575
576
  instrAccountHeaderModel.assetTokenId = buffer.readUint32LE(4);
@@ -670,7 +671,7 @@ class Engine {
670
671
  }
671
672
  getInstrAccountByTag(args) {
672
673
  return __awaiter(this, void 0, void 0, function* () {
673
- let buf = Buffer.alloc(16);
674
+ let buf = buffer_1.Buffer.alloc(16);
674
675
  buf.writeInt32LE(this.version, 0);
675
676
  buf.writeInt32LE(args.tag, 4);
676
677
  buf.writeInt32LE(args.assetTokenId, 8);
@@ -684,7 +685,7 @@ class Engine {
684
685
  }
685
686
  getAccountByTag(tag) {
686
687
  return __awaiter(this, void 0, void 0, function* () {
687
- let buf = Buffer.alloc(8);
688
+ let buf = buffer_1.Buffer.alloc(8);
688
689
  buf.writeInt32LE(this.version, 0);
689
690
  buf.writeInt32LE(tag, 4);
690
691
  const address = (yield (0, kit_1.getProgramDerivedAddress)({
@@ -946,7 +947,7 @@ class Engine {
946
947
  }
947
948
  getTokenAccount(mint) {
948
949
  return __awaiter(this, void 0, void 0, function* () {
949
- let buf = Buffer.from((0, kit_1.getAddressEncoder)().encode(mint).buffer);
950
+ let buf = buffer_1.Buffer.from((0, kit_1.getAddressEncoder)().encode(mint).buffer);
950
951
  buf.writeInt32LE(this.version, 28);
951
952
  const address = (yield (0, kit_1.getProgramDerivedAddress)({
952
953
  programAddress: this.programId,
@@ -968,7 +969,7 @@ class Engine {
968
969
  return null;
969
970
  }
970
971
  else {
971
- const data = Buffer.from((0, kit_1.getBase64Encoder)().encode(info.value.data[0]));
972
+ const data = buffer_1.Buffer.from((0, kit_1.getBase64Encoder)().encode(info.value.data[0]));
972
973
  return data.readUInt32LE(0);
973
974
  }
974
975
  });
@@ -980,7 +981,7 @@ class Engine {
980
981
  */
981
982
  getInstrId(args) {
982
983
  return __awaiter(this, void 0, void 0, function* () {
983
- let buf = Buffer.alloc(16);
984
+ let buf = buffer_1.Buffer.alloc(16);
984
985
  buf.writeInt32LE(this.version, 0);
985
986
  buf.writeInt32LE(types_1.AccountType.INSTR, 4);
986
987
  buf.writeInt32LE(args.assetTokenId, 8);
@@ -995,7 +996,7 @@ class Engine {
995
996
  return null;
996
997
  }
997
998
  else {
998
- const data = Buffer.from((0, kit_1.getBase64Encoder)().encode(info.value.data[0]));
999
+ const data = buffer_1.Buffer.from((0, kit_1.getBase64Encoder)().encode(info.value.data[0]));
999
1000
  return data.readUInt32LE(0);
1000
1001
  }
1001
1002
  });
@@ -1007,7 +1008,7 @@ class Engine {
1007
1008
  setSigner(signer) {
1008
1009
  return __awaiter(this, void 0, void 0, function* () {
1009
1010
  this.signer = signer;
1010
- let buf = Buffer.alloc(8);
1011
+ let buf = buffer_1.Buffer.alloc(8);
1011
1012
  buf.writeUint32LE(this.version, 0);
1012
1013
  buf.writeUint32LE(types_1.AccountType.CLIENT_PRIMARY, 4);
1013
1014
  const clientPrimaryAccount = yield this.findClientPrimaryAccount(signer);
@@ -1051,7 +1052,7 @@ class Engine {
1051
1052
  }
1052
1053
  findClientPrimaryAccount(wallet) {
1053
1054
  return __awaiter(this, void 0, void 0, function* () {
1054
- let tagBuf = Buffer.alloc(8);
1055
+ let tagBuf = buffer_1.Buffer.alloc(8);
1055
1056
  tagBuf.writeUint32LE(this.version, 0);
1056
1057
  tagBuf.writeUint32LE(types_1.AccountType.CLIENT_PRIMARY, 4);
1057
1058
  let source = (wallet == null || wallet == undefined) ? this.signer : wallet;
@@ -1064,7 +1065,7 @@ class Engine {
1064
1065
  }
1065
1066
  findClientCommunityAccount(wallet) {
1066
1067
  return __awaiter(this, void 0, void 0, function* () {
1067
- let tagBuf = Buffer.alloc(8);
1068
+ let tagBuf = buffer_1.Buffer.alloc(8);
1068
1069
  tagBuf.writeUint32LE(this.version, 0);
1069
1070
  tagBuf.writeUint32LE(types_1.AccountType.CLIENT_COMMUNITY, 4);
1070
1071
  let source = (wallet == null || wallet == undefined) ? this.signer : wallet;
@@ -1077,7 +1078,7 @@ class Engine {
1077
1078
  }
1078
1079
  findClientDrvAccount() {
1079
1080
  return __awaiter(this, void 0, void 0, function* () {
1080
- let tagBuf = Buffer.alloc(8);
1081
+ let tagBuf = buffer_1.Buffer.alloc(8);
1081
1082
  tagBuf.writeUint32LE(this.version, 0);
1082
1083
  tagBuf.writeUint32LE(types_1.AccountType.CLIENT_DRV, 4);
1083
1084
  const address = (yield (0, kit_1.getProgramDerivedAddress)({
@@ -1134,7 +1135,7 @@ class Engine {
1134
1135
  }
1135
1136
  const clientPrimaryAccountHeaderModel = structure_models_1.ClientPrimaryAccountHeaderModel.fromBuffer(infos.value[0].data);
1136
1137
  let clientCommunityAccountHeaderModel = structure_models_1.ClientCommunityAccountHeaderModel.fromBuffer(infos.value[1].data);
1137
- const primaryData = Buffer.from((0, kit_1.getBase64Encoder)().encode(infos.value[0].data[0]));
1138
+ const primaryData = buffer_1.Buffer.from((0, kit_1.getBase64Encoder)().encode(infos.value[0].data[0]));
1138
1139
  let tokens = new Map();
1139
1140
  let lp = new Map();
1140
1141
  let spot = new Map();
@@ -1265,8 +1266,8 @@ class Engine {
1265
1266
  if (infos.value[0] == null || infos.value[1] == null) {
1266
1267
  throw new Error("Orders Info Not Found");
1267
1268
  }
1268
- const data = Buffer.from((0, kit_1.getBase64Encoder)().encode(infos.value[0].data[0]));
1269
- const data1 = Buffer.from((0, kit_1.getBase64Encoder)().encode(infos.value[1].data[0]));
1269
+ const data = buffer_1.Buffer.from((0, kit_1.getBase64Encoder)().encode(infos.value[0].data[0]));
1270
+ const data1 = buffer_1.Buffer.from((0, kit_1.getBase64Encoder)().encode(infos.value[1].data[0]));
1270
1271
  return {
1271
1272
  contextSlot: Number(infos.context.slot),
1272
1273
  bidSlot: data1.readUint32LE(structure_models_1.SpotClientInfo2Model.OFFSET_BID_SLOT),
@@ -1645,7 +1646,7 @@ class Engine {
1645
1646
  line.qty /= assetTokenDec;
1646
1647
  perpAsks.push(line);
1647
1648
  }
1648
- let pattern = Buffer.alloc(16);
1649
+ let pattern = buffer_1.Buffer.alloc(16);
1649
1650
  pattern.writeInt32LE(this.version, 0);
1650
1651
  pattern.writeInt32LE(types_1.AccountType.INSTR, 4);
1651
1652
  pattern.writeInt32LE(header.assetTokenId, 8);
@@ -2334,7 +2335,7 @@ class Engine {
2334
2335
  if (!(yield this.checkClient())) {
2335
2336
  throw new Error("Client account not found");
2336
2337
  }
2337
- let buf = Buffer.alloc(1);
2338
+ let buf = buffer_1.Buffer.alloc(1);
2338
2339
  buf.writeUInt8(45, 0);
2339
2340
  let keys = [
2340
2341
  { address: this.signer, role: kit_1.AccountRole.READONLY_SIGNER },
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  export declare function newOperatorData(tag: number, version: number): Buffer;
3
4
  export declare function newRootAccountData(tag: number, lutSlot: number): Buffer;
4
5
  export declare function newSpotOrderData(tag: number, ioc: number, orderType: number, side: number, instrId: number, price: number, amount: number): Buffer;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  export declare enum LogType {
3
4
  deposit = 1,
4
5
  withdraw = 2,
@@ -59,14 +60,14 @@ export declare class EarningsReportModel {
59
60
  static readonly LENGTH: number;
60
61
  static readonly OFFSET_TAG = 0;
61
62
  static readonly OFFSET_CLIENT_ID = 4;
62
- static readonly OFFSET_AMOUNT = 8;
63
- static readonly OFFSET_TIME = 16;
64
- static readonly OFFSET_TOKEN_ID = 20;
63
+ static readonly OFFSET_TOKEN_ID = 8;
64
+ static readonly OFFSET_TIME = 12;
65
+ static readonly OFFSET_AMOUNT = 16;
65
66
  tag: number;
66
67
  clientId: number;
67
- amount: number;
68
- time: number;
69
68
  tokenId: number;
69
+ time: number;
70
+ amount: number;
70
71
  static fromBuffer(buffer: Buffer, offset?: number): EarningsReportModel;
71
72
  }
72
73
  export declare class DepositReportModel {
@@ -81,9 +81,9 @@ class EarningsReportModel {
81
81
  autoBuffer.readU8();
82
82
  autoBuffer.readU16();
83
83
  result.clientId = autoBuffer.readU32();
84
- result.amount = autoBuffer.readI64();
85
- result.time = autoBuffer.readU32();
86
84
  result.tokenId = autoBuffer.readU32();
85
+ result.time = autoBuffer.readU32();
86
+ result.amount = autoBuffer.readI64();
87
87
  return result;
88
88
  }
89
89
  }
@@ -91,9 +91,9 @@ exports.EarningsReportModel = EarningsReportModel;
91
91
  EarningsReportModel.LENGTH = 2 * 1 + 1 * 2 + 3 * 4 + 1 * 8; // 24 bytes
92
92
  EarningsReportModel.OFFSET_TAG = 0;
93
93
  EarningsReportModel.OFFSET_CLIENT_ID = 4;
94
- EarningsReportModel.OFFSET_AMOUNT = 8;
95
- EarningsReportModel.OFFSET_TIME = 16;
96
- EarningsReportModel.OFFSET_TOKEN_ID = 20;
94
+ EarningsReportModel.OFFSET_TOKEN_ID = 8;
95
+ EarningsReportModel.OFFSET_TIME = 12;
96
+ EarningsReportModel.OFFSET_AMOUNT = 16;
97
97
  class DepositReportModel {
98
98
  static fromBuffer(buffer, offset) {
99
99
  const result = new DepositReportModel();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deriverse/kit",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,15 +12,13 @@
12
12
  "author": "Deriverse",
13
13
  "license": "Apache-2.0",
14
14
  "devDependencies": {
15
- "typedoc": "^0.25.13",
15
+ "@types/node": "^22.14.0",
16
16
  "typescript": "^5.4.3"
17
17
  },
18
18
  "dependencies": {
19
- "@solana/spl-token": "^0.4.6",
20
- "@solana/kit": "^2.1.0",
21
19
  "@solana-program/system": "^0.7.0",
22
- "bigint-buffer": "^1.1.5",
23
- "bs58": "^5.0.0",
24
- "base64-arraybuffer": "^1.0.2"
20
+ "@solana/kit": "^2.1.0",
21
+ "base64-arraybuffer": "^1.0.2",
22
+ "bs58": "^5.0.0"
25
23
  }
26
24
  }