@reflectmoney/oracle.ts 3.1.0 → 3.2.1

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.d.ts CHANGED
@@ -25,27 +25,10 @@ export interface PayloadSerializer<T> {
25
25
  deserialize(buffer: Buffer): T;
26
26
  size(): number;
27
27
  }
28
- /**
29
- * Built-in serializer for [u8; 8] payloads (used for price feeds)
30
- * The payload is simply 8 bytes representing data in little-endian format
31
- */
32
- export declare class U8Array8Serializer implements PayloadSerializer<Buffer> {
33
- serialize(payload: Buffer): Buffer;
34
- deserialize(buffer: Buffer): Buffer;
35
- size(): number;
36
- }
37
- /**
38
- * Helper function to create a [u8; 8] payload from a bigint price value
39
- */
40
- export declare function createPricePayload(price: bigint): Buffer;
41
28
  /**
42
29
  * Helper function to create a PriceData payload buffer from price and precision
43
30
  */
44
31
  export declare function createPriceDataPayload(price: bigint, precision: number): Buffer;
45
- /**
46
- * Helper function to read a price value from a [u8; 8] payload
47
- */
48
- export declare function readPriceFromPayload(payload: Buffer): bigint;
49
32
  /**
50
33
  * Helper function to read PriceData from a buffer payload
51
34
  */
package/dist/index.js CHANGED
@@ -9,10 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Doppler = exports.TransactionBuilder = exports.PriceDataSerializer = exports.U8Array8Serializer = exports.ADMIN_PUBKEY = exports.DOPPLER_PROGRAM_ID = void 0;
13
- exports.createPricePayload = createPricePayload;
12
+ exports.Doppler = exports.TransactionBuilder = exports.PriceDataSerializer = exports.ADMIN_PUBKEY = exports.DOPPLER_PROGRAM_ID = void 0;
14
13
  exports.createPriceDataPayload = createPriceDataPayload;
15
- exports.readPriceFromPayload = readPriceFromPayload;
16
14
  exports.readPriceDataFromPayload = readPriceDataFromPayload;
17
15
  const web3_js_1 = require("@solana/web3.js");
18
16
  const buffer_1 = require("buffer");
@@ -24,7 +22,7 @@ exports.ADMIN_PUBKEY = new web3_js_1.PublicKey('pRiCEzwgkSi7KTsQHdyfuRbPEuCFoK9s
24
22
  // Constants for compute unit calculations
25
23
  const SEQUENCE_CHECK_CU = 5;
26
24
  const ADMIN_VERIFICATION_CU = 6;
27
- const PAYLOAD_WRITE_CU = 6;
25
+ const PAYLOAD_WRITE_CU = 8;
28
26
  const COMPUTE_BUDGET_IX_CU = 150;
29
27
  const COMPUTE_BUDGET_UNIT_PRICE_SIZE = 9;
30
28
  const COMPUTE_BUDGET_UNIT_LIMIT_SIZE = 5;
@@ -32,36 +30,6 @@ const COMPUTE_BUDGET_DATA_LIMIT_SIZE = 5;
32
30
  const COMPUTE_BUDGET_PROGRAM_SIZE = 22;
33
31
  const ORACLE_PROGRAM_SIZE = 36;
34
32
  const READ_CLOCK_CU = 11;
35
- /**
36
- * Built-in serializer for [u8; 8] payloads (used for price feeds)
37
- * The payload is simply 8 bytes representing data in little-endian format
38
- */
39
- class U8Array8Serializer {
40
- serialize(payload) {
41
- if (payload.length !== 8) {
42
- throw new Error('Payload must be exactly 8 bytes');
43
- }
44
- return payload;
45
- }
46
- deserialize(buffer) {
47
- if (buffer.length < 8) {
48
- throw new Error('Buffer must be at least 8 bytes');
49
- }
50
- return buffer.subarray(0, 8);
51
- }
52
- size() {
53
- return 8;
54
- }
55
- }
56
- exports.U8Array8Serializer = U8Array8Serializer;
57
- /**
58
- * Helper function to create a [u8; 8] payload from a bigint price value
59
- */
60
- function createPricePayload(price) {
61
- const buf = buffer_1.Buffer.alloc(8);
62
- buf.writeBigUInt64LE(price);
63
- return buf;
64
- }
65
33
  /**
66
34
  * Helper function to create a PriceData payload buffer from price and precision
67
35
  */
@@ -71,15 +39,6 @@ function createPriceDataPayload(price, precision) {
71
39
  buf.writeUInt8(precision, 8);
72
40
  return buf;
73
41
  }
74
- /**
75
- * Helper function to read a price value from a [u8; 8] payload
76
- */
77
- function readPriceFromPayload(payload) {
78
- if (payload.length < 8) {
79
- throw new Error('Payload must be at least 8 bytes');
80
- }
81
- return payload.readBigUInt64LE(0);
82
- }
83
42
  /**
84
43
  * Helper function to read PriceData from a buffer payload
85
44
  */
@@ -140,8 +99,7 @@ class TransactionBuilder {
140
99
  SEQUENCE_CHECK_CU +
141
100
  ADMIN_VERIFICATION_CU +
142
101
  PAYLOAD_WRITE_CU +
143
- Math.floor(oracleSize / 4) +
144
- READ_CLOCK_CU;
102
+ Math.floor(oracleSize / 4);
145
103
  this.loadedAccountDataSize += oracleSize * 2;
146
104
  this.oracleUpdateInstructions.push(instruction);
147
105
  return this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reflectmoney/oracle.ts",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
4
4
  "type": "commonjs",
5
5
  "author": "L0STE, stablecoinjesus @ Palindrome Engineering",
6
6
  "repository": {