@acta-markets/ts-sdk 0.0.8-beta → 0.0.10-beta

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.
@@ -101,7 +101,8 @@ describe("fetch offsets and order encode", () => {
101
101
  quantity: 0x1111222233334444n,
102
102
  totalPremium: 0x9999888877776666n,
103
103
  orderId: new Uint8Array(32).fill(0x88),
104
- reserved: Array(32).fill(0n),
104
+ createdAt: 0n,
105
+ reserved: Array(31).fill(0n),
105
106
  });
106
107
  expect(positionData.length).toBe(getPositionSize());
107
108
  expect(positionData[POSITION_OFFSET_STATUS]).toBe(3);
@@ -179,7 +180,8 @@ describe("fetch offsets and order encode", () => {
179
180
  quantity: 1n,
180
181
  totalPremium: 1n,
181
182
  orderId: new Uint8Array(32).fill(0x11),
182
- reserved: Array(32).fill(0n),
183
+ createdAt: 0n,
184
+ reserved: Array(31).fill(0n),
183
185
  });
184
186
  expect(() => decodeMarketAccount(Buffer.from(positionData))).toThrow("Invalid Market account discriminator");
185
187
  expect(() => decodeMarketAccount(Buffer.alloc(8))).toThrow("Invalid Market account size");
@@ -103,7 +103,8 @@ describe("fetch offsets and order encode", () => {
103
103
  quantity: 0x1111222233334444n,
104
104
  totalPremium: 0x9999888877776666n,
105
105
  orderId: new Uint8Array(32).fill(0x88),
106
- reserved: Array(32).fill(0n),
106
+ createdAt: 0n,
107
+ reserved: Array(31).fill(0n),
107
108
  });
108
109
  expect(positionData.length).toBe((0, position_1.getPositionSize)());
109
110
  expect(positionData[fetch_1.POSITION_OFFSET_STATUS]).toBe(3);
@@ -181,7 +182,8 @@ describe("fetch offsets and order encode", () => {
181
182
  quantity: 1n,
182
183
  totalPremium: 1n,
183
184
  orderId: new Uint8Array(32).fill(0x11),
184
- reserved: Array(32).fill(0n),
185
+ createdAt: 0n,
186
+ reserved: Array(31).fill(0n),
185
187
  });
186
188
  expect(() => (0, fetch_1.decodeMarketAccount)(buffer_1.Buffer.from(positionData))).toThrow("Invalid Market account discriminator");
187
189
  expect(() => (0, fetch_1.decodeMarketAccount)(buffer_1.Buffer.alloc(8))).toThrow("Invalid Market account size");
@@ -309,6 +309,7 @@ describe("events parsing", () => {
309
309
  u64(4000),
310
310
  Buffer.from(orderId),
311
311
  u64(5000), // total_premium
312
+ u64(6000), // created_at
312
313
  ]));
313
314
  const d = (0, events_1.decodeActaEventLine)(line);
314
315
  expect(d.kind).toBe(events_1.EventKind.OpenPosition);
@@ -325,6 +326,7 @@ describe("events parsing", () => {
325
326
  expect(d.event.validUntil).toBe(4000n);
326
327
  expect(Buffer.from(d.event.orderId)).toEqual(Buffer.from(orderId));
327
328
  expect(d.event.totalPremium).toBe(5000n);
329
+ expect(d.event.createdAt).toBe(6000n);
328
330
  }
329
331
  }
330
332
  // 12: DepositFundsToPosition
@@ -35,7 +35,8 @@ function getPositionEncoder() {
35
35
  ["quantity", (0, kit_1.getU64Encoder)()],
36
36
  ["totalPremium", (0, kit_1.getU64Encoder)()],
37
37
  ["orderId", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 32)],
38
- ["reserved", (0, kit_1.getArrayEncoder)((0, kit_1.getU64Encoder)(), { size: 32 })],
38
+ ["createdAt", (0, kit_1.getU64Encoder)()],
39
+ ["reserved", (0, kit_1.getArrayEncoder)((0, kit_1.getU64Encoder)(), { size: 31 })],
39
40
  ]);
40
41
  }
41
42
  /** Gets the decoder for {@link Position} account data. */
@@ -56,7 +57,8 @@ function getPositionDecoder() {
56
57
  ["quantity", (0, kit_1.getU64Decoder)()],
57
58
  ["totalPremium", (0, kit_1.getU64Decoder)()],
58
59
  ["orderId", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 32)],
59
- ["reserved", (0, kit_1.getArrayDecoder)((0, kit_1.getU64Decoder)(), { size: 32 })],
60
+ ["createdAt", (0, kit_1.getU64Decoder)()],
61
+ ["reserved", (0, kit_1.getArrayDecoder)((0, kit_1.getU64Decoder)(), { size: 31 })],
60
62
  ]);
61
63
  }
62
64
  /** Gets the codec for {@link Position} account data. */
@@ -7,7 +7,7 @@
7
7
  * @see https://github.com/codama-idl/codama
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = exports.ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED = exports.ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED = exports.ACTA_CONTRACT_ERROR__ORACLE_CLOSE_TOO_EARLY = exports.ACTA_CONTRACT_ERROR__UNAUTHORIZED = exports.ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP = exports.ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID = exports.ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS = exports.ACTA_CONTRACT_ERROR__MINT_MISMATCH = exports.ACTA_CONTRACT_ERROR__MATH_OVERFLOW = exports.ACTA_CONTRACT_ERROR__INVALID_INSTRUCTION_DATA = exports.ACTA_CONTRACT_ERROR__SIGNED_MESSAGE_MISMATCH = exports.ACTA_CONTRACT_ERROR__SIGNER_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORDER_ID = exports.ACTA_CONTRACT_ERROR__POSITION_TYPE_MISMATCH = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_ITM = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_SETTLED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_OPEN = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_OPEN = exports.ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE = exports.ACTA_CONTRACT_ERROR__ORACLE_INACTIVE = exports.ACTA_CONTRACT_ERROR__ORACLE_STALE = exports.ACTA_CONTRACT_ERROR__ORACLE_EXPIRY_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_ACCOUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_TYPE = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EMPTY = exports.ACTA_CONTRACT_ERROR__MARKET_EXPIRED = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_FINALIZED = exports.ACTA_CONTRACT_ERROR__MARKET_FINALIZED = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED = exports.ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED = exports.ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT = exports.ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_PDA = exports.ACTA_CONTRACT_ERROR__INVALID_OWNER = exports.ACTA_CONTRACT_ERROR__NOT_SIGNED = void 0;
10
+ exports.ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = exports.ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = exports.ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED = exports.ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED = exports.ACTA_CONTRACT_ERROR__ORACLE_CLOSE_TOO_EARLY = exports.ACTA_CONTRACT_ERROR__UNAUTHORIZED = exports.ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP = exports.ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID = exports.ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS = exports.ACTA_CONTRACT_ERROR__MINT_MISMATCH = exports.ACTA_CONTRACT_ERROR__MATH_OVERFLOW = exports.ACTA_CONTRACT_ERROR__INVALID_INSTRUCTION_DATA = exports.ACTA_CONTRACT_ERROR__SIGNED_MESSAGE_MISMATCH = exports.ACTA_CONTRACT_ERROR__SIGNER_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORDER_ID = exports.ACTA_CONTRACT_ERROR__POSITION_TYPE_MISMATCH = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_ITM = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_SETTLED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED = exports.ACTA_CONTRACT_ERROR__POSITION_NOT_OPEN = exports.ACTA_CONTRACT_ERROR__POSITION_ALREADY_OPEN = exports.ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE = exports.ACTA_CONTRACT_ERROR__ORACLE_INACTIVE = exports.ACTA_CONTRACT_ERROR__ORACLE_STALE = exports.ACTA_CONTRACT_ERROR__ORACLE_EXPIRY_MISMATCH = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_ACCOUNT = exports.ACTA_CONTRACT_ERROR__INVALID_ORACLE_TYPE = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_EMPTY = exports.ACTA_CONTRACT_ERROR__MARKET_EXPIRED = exports.ACTA_CONTRACT_ERROR__MARKET_NOT_FINALIZED = exports.ACTA_CONTRACT_ERROR__MARKET_FINALIZED = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER = exports.ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED = exports.ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED = exports.ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA = exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT = exports.ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED = exports.ACTA_CONTRACT_ERROR__INVALID_PDA = exports.ACTA_CONTRACT_ERROR__INVALID_OWNER = exports.ACTA_CONTRACT_ERROR__NOT_SIGNED = void 0;
11
11
  exports.getActaContractErrorMessage = getActaContractErrorMessage;
12
12
  exports.isActaContractError = isActaContractError;
13
13
  const kit_1 = require("@solana/kit");
@@ -96,11 +96,14 @@ exports.ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED = 0x430; // 1072
96
96
  exports.ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED = 0x431; // 1073
97
97
  /** OracleHasActiveMarkets: Oracle is still linked to active markets */
98
98
  exports.ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = 0x432; // 1074
99
+ /** DuplicateAccount: Duplicate account passed to instruction */
100
+ exports.ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 0x433; // 1075
99
101
  let actaContractErrorMessages;
100
102
  if (process.env.NODE_ENV !== "production") {
101
103
  actaContractErrorMessages = {
102
104
  [exports.ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED]: `Account already initialized`,
103
105
  [exports.ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED]: `Account not initialized`,
106
+ [exports.ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT]: `Duplicate account passed to instruction`,
104
107
  [exports.ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS]: `Balance is below the required amount`,
105
108
  [exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT]: `Wrong number of accounts`,
106
109
  [exports.ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA]: `Account data corrupted or wrong format`,
@@ -115,6 +115,7 @@ function getActaEventEncoder() {
115
115
  ["validUntil", (0, kit_1.getU64Encoder)()],
116
116
  ["orderId", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 32)],
117
117
  ["totalPremium", (0, kit_1.getU64Encoder)()],
118
+ ["createdAt", (0, kit_1.getU64Encoder)()],
118
119
  ]),
119
120
  ],
120
121
  [
@@ -276,6 +277,7 @@ function getActaEventDecoder() {
276
277
  ["validUntil", (0, kit_1.getU64Decoder)()],
277
278
  ["orderId", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 32)],
278
279
  ["totalPremium", (0, kit_1.getU64Decoder)()],
280
+ ["createdAt", (0, kit_1.getU64Decoder)()],
279
281
  ]),
280
282
  ],
281
283
  [
@@ -1596,12 +1596,16 @@
1596
1596
  ]
1597
1597
  }
1598
1598
  },
1599
+ {
1600
+ "name": "createdAt",
1601
+ "type": "u64"
1602
+ },
1599
1603
  {
1600
1604
  "name": "reserved",
1601
1605
  "type": {
1602
1606
  "array": [
1603
1607
  "u64",
1604
- 32
1608
+ 31
1605
1609
  ]
1606
1610
  }
1607
1611
  }
@@ -1967,6 +1971,10 @@
1967
1971
  {
1968
1972
  "name": "total_premium",
1969
1973
  "type": "u64"
1974
+ },
1975
+ {
1976
+ "name": "created_at",
1977
+ "type": "u64"
1970
1978
  }
1971
1979
  ]
1972
1980
  },
@@ -2341,6 +2349,11 @@
2341
2349
  "code": 1074,
2342
2350
  "name": "OracleHasActiveMarkets",
2343
2351
  "msg": "Oracle is still linked to active markets"
2352
+ },
2353
+ {
2354
+ "code": 1075,
2355
+ "name": "DuplicateAccount",
2356
+ "msg": "Duplicate account passed to instruction"
2344
2357
  }
2345
2358
  ]
2346
2359
  }
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ACTA_IDL_SHA256 = void 0;
4
- exports.ACTA_IDL_SHA256 = "704677f7071ecbe98f442fb62468d882329b906950a707fc47aad0f38683636f";
4
+ exports.ACTA_IDL_SHA256 = "2f68d4442e5eb2098a5cdc76fb3465c48d6aff9bc1cda6b27f3b45eeff35bffb";
@@ -311,6 +311,14 @@ class ActaWsClient extends TypedEventEmitter {
311
311
  });
312
312
  return requestId;
313
313
  }
314
+ getTokenCaps(args) {
315
+ const requestId = this.nextRequestId();
316
+ this.send({
317
+ type: "GetTokenCaps",
318
+ data: { request_id: requestId, include_markets: args?.include_markets },
319
+ });
320
+ return requestId;
321
+ }
314
322
  logout() {
315
323
  this.send({ type: "Logout" });
316
324
  }
@@ -406,7 +414,7 @@ class ActaWsClient extends TypedEventEmitter {
406
414
  }
407
415
  this.setConnectionState("connecting");
408
416
  this.emit("connecting");
409
- const endpoint = this.options.role === "maker" ? "/maker" : "/taker";
417
+ const endpoint = this.options.role === "maker" ? "/ws/maker" : "/ws/taker";
410
418
  const url = `${this.options.url}${endpoint}`;
411
419
  this.log(`Connecting to ${url}`);
412
420
  const ws = this.options.makeSocket(url);
@@ -535,6 +543,12 @@ class ActaWsClient extends TypedEventEmitter {
535
543
  }
536
544
  this.emit("activeRfqs", message.data.rfqs);
537
545
  break;
546
+ case "TokenCaps":
547
+ this.emit("tokenCaps", message.data);
548
+ break;
549
+ case "MyCaps":
550
+ this.emit("myCaps", message.data);
551
+ break;
538
552
  case "MyActiveRfqs":
539
553
  this.handleMyActiveRfqs(message.data);
540
554
  break;
@@ -669,6 +683,9 @@ class ActaWsClient extends TypedEventEmitter {
669
683
  case "ChainEvent":
670
684
  this.handleChainEvent(message.data);
671
685
  break;
686
+ case "RfqSkipped":
687
+ this.emit("rfqSkipped", message.data);
688
+ break;
672
689
  case "Pong":
673
690
  break;
674
691
  case "Error":
@@ -307,6 +307,7 @@ describe("events parsing", () => {
307
307
  u64(4000),
308
308
  Buffer.from(orderId),
309
309
  u64(5000), // total_premium
310
+ u64(6000), // created_at
310
311
  ]));
311
312
  const d = decodeActaEventLine(line);
312
313
  expect(d.kind).toBe(EventKind.OpenPosition);
@@ -323,6 +324,7 @@ describe("events parsing", () => {
323
324
  expect(d.event.validUntil).toBe(4000n);
324
325
  expect(Buffer.from(d.event.orderId)).toEqual(Buffer.from(orderId));
325
326
  expect(d.event.totalPremium).toBe(5000n);
327
+ expect(d.event.createdAt).toBe(6000n);
326
328
  }
327
329
  }
328
330
  // 12: DepositFundsToPosition
@@ -22,6 +22,7 @@ export type Position = {
22
22
  quantity: bigint;
23
23
  totalPremium: bigint;
24
24
  orderId: ReadonlyUint8Array;
25
+ createdAt: bigint;
25
26
  reserved: Array<bigint>;
26
27
  };
27
28
  export type PositionArgs = {
@@ -40,6 +41,7 @@ export type PositionArgs = {
40
41
  quantity: number | bigint;
41
42
  totalPremium: number | bigint;
42
43
  orderId: ReadonlyUint8Array;
44
+ createdAt: number | bigint;
43
45
  reserved: Array<number | bigint>;
44
46
  };
45
47
  /** Gets the encoder for {@link PositionArgs} account data. */
@@ -24,7 +24,8 @@ export function getPositionEncoder() {
24
24
  ["quantity", getU64Encoder()],
25
25
  ["totalPremium", getU64Encoder()],
26
26
  ["orderId", fixEncoderSize(getBytesEncoder(), 32)],
27
- ["reserved", getArrayEncoder(getU64Encoder(), { size: 32 })],
27
+ ["createdAt", getU64Encoder()],
28
+ ["reserved", getArrayEncoder(getU64Encoder(), { size: 31 })],
28
29
  ]);
29
30
  }
30
31
  /** Gets the decoder for {@link Position} account data. */
@@ -45,7 +46,8 @@ export function getPositionDecoder() {
45
46
  ["quantity", getU64Decoder()],
46
47
  ["totalPremium", getU64Decoder()],
47
48
  ["orderId", fixDecoderSize(getBytesDecoder(), 32)],
48
- ["reserved", getArrayDecoder(getU64Decoder(), { size: 32 })],
49
+ ["createdAt", getU64Decoder()],
50
+ ["reserved", getArrayDecoder(getU64Decoder(), { size: 31 })],
49
51
  ]);
50
52
  }
51
53
  /** Gets the codec for {@link Position} account data. */
@@ -90,7 +90,9 @@ export declare const ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED = 1072;
90
90
  export declare const ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED = 1073;
91
91
  /** OracleHasActiveMarkets: Oracle is still linked to active markets */
92
92
  export declare const ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = 1074;
93
- export type ActaContractError = typeof ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED | typeof ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED | typeof ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS | typeof ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT | typeof ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA | typeof ACTA_CONTRACT_ERROR__INVALID_INSTRUCTION_DATA | typeof ACTA_CONTRACT_ERROR__INVALID_ORACLE_ACCOUNT | typeof ACTA_CONTRACT_ERROR__INVALID_ORACLE_TYPE | typeof ACTA_CONTRACT_ERROR__INVALID_ORDER_ID | typeof ACTA_CONTRACT_ERROR__INVALID_OWNER | typeof ACTA_CONTRACT_ERROR__INVALID_PDA | typeof ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID | typeof ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT | typeof ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP | typeof ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED | typeof ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER | typeof ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED | typeof ACTA_CONTRACT_ERROR__MARKET_EXPIRED | typeof ACTA_CONTRACT_ERROR__MARKET_FINALIZED | typeof ACTA_CONTRACT_ERROR__MARKET_NOT_EMPTY | typeof ACTA_CONTRACT_ERROR__MARKET_NOT_FINALIZED | typeof ACTA_CONTRACT_ERROR__MATH_OVERFLOW | typeof ACTA_CONTRACT_ERROR__MINT_MISMATCH | typeof ACTA_CONTRACT_ERROR__NOT_SIGNED | typeof ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED | typeof ACTA_CONTRACT_ERROR__ORACLE_CLOSE_TOO_EARLY | typeof ACTA_CONTRACT_ERROR__ORACLE_EXPIRY_MISMATCH | typeof ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS | typeof ACTA_CONTRACT_ERROR__ORACLE_INACTIVE | typeof ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE | typeof ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED | typeof ACTA_CONTRACT_ERROR__ORACLE_STALE | typeof ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED | typeof ACTA_CONTRACT_ERROR__POSITION_ALREADY_OPEN | typeof ACTA_CONTRACT_ERROR__POSITION_ALREADY_SETTLED | typeof ACTA_CONTRACT_ERROR__POSITION_NOT_FUNDED | typeof ACTA_CONTRACT_ERROR__POSITION_NOT_ITM | typeof ACTA_CONTRACT_ERROR__POSITION_NOT_OPEN | typeof ACTA_CONTRACT_ERROR__POSITION_TYPE_MISMATCH | typeof ACTA_CONTRACT_ERROR__SIGNED_MESSAGE_MISMATCH | typeof ACTA_CONTRACT_ERROR__SIGNER_MISMATCH | typeof ACTA_CONTRACT_ERROR__UNAUTHORIZED;
93
+ /** DuplicateAccount: Duplicate account passed to instruction */
94
+ export declare const ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 1075;
95
+ export type ActaContractError = typeof ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED | typeof ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED | typeof ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT | typeof ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS | typeof ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT | typeof ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA | typeof ACTA_CONTRACT_ERROR__INVALID_INSTRUCTION_DATA | typeof ACTA_CONTRACT_ERROR__INVALID_ORACLE_ACCOUNT | typeof ACTA_CONTRACT_ERROR__INVALID_ORACLE_TYPE | typeof ACTA_CONTRACT_ERROR__INVALID_ORDER_ID | typeof ACTA_CONTRACT_ERROR__INVALID_OWNER | typeof ACTA_CONTRACT_ERROR__INVALID_PDA | typeof ACTA_CONTRACT_ERROR__INVALID_PROGRAM_ID | typeof ACTA_CONTRACT_ERROR__INVALID_SIGNATURE_COUNT | typeof ACTA_CONTRACT_ERROR__INVALID_TIMESTAMP | typeof ACTA_CONTRACT_ERROR__MAKER_ALREADY_REGISTERED | typeof ACTA_CONTRACT_ERROR__MAKER_NOT_OWNER | typeof ACTA_CONTRACT_ERROR__MAKER_NOT_REGISTERED | typeof ACTA_CONTRACT_ERROR__MARKET_EXPIRED | typeof ACTA_CONTRACT_ERROR__MARKET_FINALIZED | typeof ACTA_CONTRACT_ERROR__MARKET_NOT_EMPTY | typeof ACTA_CONTRACT_ERROR__MARKET_NOT_FINALIZED | typeof ACTA_CONTRACT_ERROR__MATH_OVERFLOW | typeof ACTA_CONTRACT_ERROR__MINT_MISMATCH | typeof ACTA_CONTRACT_ERROR__NOT_SIGNED | typeof ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED | typeof ACTA_CONTRACT_ERROR__ORACLE_CLOSE_TOO_EARLY | typeof ACTA_CONTRACT_ERROR__ORACLE_EXPIRY_MISMATCH | typeof ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS | typeof ACTA_CONTRACT_ERROR__ORACLE_INACTIVE | typeof ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE | typeof ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED | typeof ACTA_CONTRACT_ERROR__ORACLE_STALE | typeof ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED | typeof ACTA_CONTRACT_ERROR__POSITION_ALREADY_OPEN | typeof ACTA_CONTRACT_ERROR__POSITION_ALREADY_SETTLED | typeof ACTA_CONTRACT_ERROR__POSITION_NOT_FUNDED | typeof ACTA_CONTRACT_ERROR__POSITION_NOT_ITM | typeof ACTA_CONTRACT_ERROR__POSITION_NOT_OPEN | typeof ACTA_CONTRACT_ERROR__POSITION_TYPE_MISMATCH | typeof ACTA_CONTRACT_ERROR__SIGNED_MESSAGE_MISMATCH | typeof ACTA_CONTRACT_ERROR__SIGNER_MISMATCH | typeof ACTA_CONTRACT_ERROR__UNAUTHORIZED;
94
96
  export declare function getActaContractErrorMessage(code: ActaContractError): string;
95
97
  export declare function isActaContractError<TProgramErrorCode extends ActaContractError>(error: unknown, transactionMessage: {
96
98
  instructions: Record<number, {
@@ -91,11 +91,14 @@ export const ACTA_CONTRACT_ERROR__ORACLE_ALREADY_UPDATED = 0x430; // 1072
91
91
  export const ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED = 0x431; // 1073
92
92
  /** OracleHasActiveMarkets: Oracle is still linked to active markets */
93
93
  export const ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = 0x432; // 1074
94
+ /** DuplicateAccount: Duplicate account passed to instruction */
95
+ export const ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 0x433; // 1075
94
96
  let actaContractErrorMessages;
95
97
  if (process.env.NODE_ENV !== "production") {
96
98
  actaContractErrorMessages = {
97
99
  [ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED]: `Account already initialized`,
98
100
  [ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED]: `Account not initialized`,
101
+ [ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT]: `Duplicate account passed to instruction`,
99
102
  [ACTA_CONTRACT_ERROR__INSUFFICIENT_FUNDS]: `Balance is below the required amount`,
100
103
  [ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_COUNT]: `Wrong number of accounts`,
101
104
  [ACTA_CONTRACT_ERROR__INVALID_ACCOUNT_DATA]: `Account data corrupted or wrong format`,
@@ -77,6 +77,7 @@ export type ActaEvent = {
77
77
  validUntil: bigint;
78
78
  orderId: ReadonlyUint8Array;
79
79
  totalPremium: bigint;
80
+ createdAt: bigint;
80
81
  } | {
81
82
  __kind: "DepositFundsToPosition";
82
83
  makerPda: Address;
@@ -188,6 +189,7 @@ export type ActaEventArgs = {
188
189
  validUntil: number | bigint;
189
190
  orderId: ReadonlyUint8Array;
190
191
  totalPremium: number | bigint;
192
+ createdAt: number | bigint;
191
193
  } | {
192
194
  __kind: "DepositFundsToPosition";
193
195
  makerPda: Address;
@@ -108,6 +108,7 @@ export function getActaEventEncoder() {
108
108
  ["validUntil", getU64Encoder()],
109
109
  ["orderId", fixEncoderSize(getBytesEncoder(), 32)],
110
110
  ["totalPremium", getU64Encoder()],
111
+ ["createdAt", getU64Encoder()],
111
112
  ]),
112
113
  ],
113
114
  [
@@ -269,6 +270,7 @@ export function getActaEventDecoder() {
269
270
  ["validUntil", getU64Decoder()],
270
271
  ["orderId", fixDecoderSize(getBytesDecoder(), 32)],
271
272
  ["totalPremium", getU64Decoder()],
273
+ ["createdAt", getU64Decoder()],
272
274
  ]),
273
275
  ],
274
276
  [
@@ -1596,12 +1596,16 @@
1596
1596
  ]
1597
1597
  }
1598
1598
  },
1599
+ {
1600
+ "name": "createdAt",
1601
+ "type": "u64"
1602
+ },
1599
1603
  {
1600
1604
  "name": "reserved",
1601
1605
  "type": {
1602
1606
  "array": [
1603
1607
  "u64",
1604
- 32
1608
+ 31
1605
1609
  ]
1606
1610
  }
1607
1611
  }
@@ -1967,6 +1971,10 @@
1967
1971
  {
1968
1972
  "name": "total_premium",
1969
1973
  "type": "u64"
1974
+ },
1975
+ {
1976
+ "name": "created_at",
1977
+ "type": "u64"
1970
1978
  }
1971
1979
  ]
1972
1980
  },
@@ -2341,6 +2349,11 @@
2341
2349
  "code": 1074,
2342
2350
  "name": "OracleHasActiveMarkets",
2343
2351
  "msg": "Oracle is still linked to active markets"
2352
+ },
2353
+ {
2354
+ "code": 1075,
2355
+ "name": "DuplicateAccount",
2356
+ "msg": "Duplicate account passed to instruction"
2344
2357
  }
2345
2358
  ]
2346
2359
  }
@@ -1 +1 @@
1
- export declare const ACTA_IDL_SHA256 = "704677f7071ecbe98f442fb62468d882329b906950a707fc47aad0f38683636f";
1
+ export declare const ACTA_IDL_SHA256 = "2f68d4442e5eb2098a5cdc76fb3465c48d6aff9bc1cda6b27f3b45eeff35bffb";
package/dist/idl/hash.js CHANGED
@@ -1 +1 @@
1
- export const ACTA_IDL_SHA256 = "704677f7071ecbe98f442fb62468d882329b906950a707fc47aad0f38683636f";
1
+ export const ACTA_IDL_SHA256 = "2f68d4442e5eb2098a5cdc76fb3465c48d6aff9bc1cda6b27f3b45eeff35bffb";
@@ -2,7 +2,7 @@
2
2
  import type { AuthProvider } from "./auth";
3
3
  import type { SignerLike } from "../chain/orders";
4
4
  import type { Address } from "@solana/addresses";
5
- import type { ActiveRfqInfo, ChainEventMessage, GlobalStats, MarketDescriptorInfo, MarketInfo, MyActiveRfqInfo, MyActiveRfqsMessage, OrderStatusMessage, PositionInfo, QuoteAcknowledgedMessage, QuoteBestStatusMessage, QuoteCancelledMessage, QuoteMessage, QuoteRefreshRequestedMessage, QuoteOutbidMessage, QuoteReceivedMessage, QuoteSelectedMessage, QuotesUpdateMessage, RfqBroadcastMessage, RfqClosedMessage, RfqCreatedMessage, RfqRequestMessage, RfqAvailableAgainMessage, QuoteExpiredMessage, QuoteFilledMessage, IndicativePricesMessage, IndicativePricesRequestMessage, IndicativePricesResponseMessage, GetIndicativePricesMessage, RequestId, ServerMessage, SnapshotMessage, StatsDelta, SubscriptionsMessage, TokenInfo, TradeInfo, UuidString, VersionMismatchMessage, WelcomeMessage, WsChannel } from "./types";
5
+ import type { ActiveRfqInfo, ChainEventMessage, GlobalStats, MarketDescriptorInfo, MarketInfo, MyActiveRfqInfo, MyActiveRfqsMessage, OrderStatusMessage, PositionInfo, QuoteAcknowledgedMessage, QuoteBestStatusMessage, QuoteCancelledMessage, QuoteMessage, QuoteRefreshRequestedMessage, QuoteOutbidMessage, QuoteReceivedMessage, QuoteSelectedMessage, QuotesUpdateMessage, RfqBroadcastMessage, RfqClosedMessage, RfqCreatedMessage, RfqSkippedMessage, RfqRequestMessage, RfqAvailableAgainMessage, QuoteExpiredMessage, QuoteFilledMessage, IndicativePricesMessage, IndicativePricesRequestMessage, IndicativePricesResponseMessage, GetIndicativePricesMessage, RequestId, ServerMessage, SnapshotMessage, StatsDelta, SubscriptionsMessage, TokenInfo, TradeInfo, UuidString, VersionMismatchMessage, WelcomeMessage, WsChannel } from "./types";
6
6
  export type ConnectionState = "disconnected" | "connecting" | "authenticating" | "authenticated" | "error";
7
7
  export type ClientRole = "taker" | "maker";
8
8
  export type PendingMessagesOverflowPolicy = "drop_oldest" | "drop_newest" | "throw";
@@ -76,6 +76,7 @@ export type ActaWsClientEvents = {
76
76
  subscriptions: (msg: SubscriptionsMessage) => void;
77
77
  activeRfqs: (rfqs: ActiveRfqInfo[]) => void;
78
78
  rfqBroadcast: (rfq: RfqBroadcastMessage) => void;
79
+ rfqSkipped: (msg: RfqSkippedMessage) => void;
79
80
  rfqCreated: (msg: RfqCreatedMessage) => void;
80
81
  rfqClosed: (msg: RfqClosedMessage) => void;
81
82
  quoteReceived: (quote: QuoteReceivedMessage) => void;
@@ -213,6 +214,9 @@ export declare class ActaWsClient extends TypedEventEmitter<ActaWsClientEvents>
213
214
  }): RequestId;
214
215
  getMyActiveRfqs(): RequestId;
215
216
  getActiveRfqs(): RequestId;
217
+ getTokenCaps(args?: {
218
+ include_markets?: boolean;
219
+ }): RequestId;
216
220
  logout(): void;
217
221
  getOrderStatus(orderIdHex: string): RequestId;
218
222
  cancelRfq(rfqId: string): RequestId;
package/dist/ws/client.js CHANGED
@@ -308,6 +308,14 @@ export class ActaWsClient extends TypedEventEmitter {
308
308
  });
309
309
  return requestId;
310
310
  }
311
+ getTokenCaps(args) {
312
+ const requestId = this.nextRequestId();
313
+ this.send({
314
+ type: "GetTokenCaps",
315
+ data: { request_id: requestId, include_markets: args?.include_markets },
316
+ });
317
+ return requestId;
318
+ }
311
319
  logout() {
312
320
  this.send({ type: "Logout" });
313
321
  }
@@ -403,7 +411,7 @@ export class ActaWsClient extends TypedEventEmitter {
403
411
  }
404
412
  this.setConnectionState("connecting");
405
413
  this.emit("connecting");
406
- const endpoint = this.options.role === "maker" ? "/maker" : "/taker";
414
+ const endpoint = this.options.role === "maker" ? "/ws/maker" : "/ws/taker";
407
415
  const url = `${this.options.url}${endpoint}`;
408
416
  this.log(`Connecting to ${url}`);
409
417
  const ws = this.options.makeSocket(url);
@@ -532,6 +540,12 @@ export class ActaWsClient extends TypedEventEmitter {
532
540
  }
533
541
  this.emit("activeRfqs", message.data.rfqs);
534
542
  break;
543
+ case "TokenCaps":
544
+ this.emit("tokenCaps", message.data);
545
+ break;
546
+ case "MyCaps":
547
+ this.emit("myCaps", message.data);
548
+ break;
535
549
  case "MyActiveRfqs":
536
550
  this.handleMyActiveRfqs(message.data);
537
551
  break;
@@ -666,6 +680,9 @@ export class ActaWsClient extends TypedEventEmitter {
666
680
  case "ChainEvent":
667
681
  this.handleChainEvent(message.data);
668
682
  break;
683
+ case "RfqSkipped":
684
+ this.emit("rfqSkipped", message.data);
685
+ break;
669
686
  case "Pong":
670
687
  break;
671
688
  case "Error":
@@ -157,6 +157,12 @@ export type ClientMessage = {
157
157
  } | {
158
158
  type: "GetMakerBalances";
159
159
  data: GetMakerBalancesMessage;
160
+ } | {
161
+ type: "GetTokenCaps";
162
+ data: GetTokenCapsMessage;
163
+ } | {
164
+ type: "GetMyCaps";
165
+ data: GetMyCapsMessage;
160
166
  } | {
161
167
  type: "GetSubscriptions";
162
168
  data: GetSubscriptionsMessage;
@@ -373,6 +379,12 @@ export type ServerMessage = {
373
379
  } | {
374
380
  type: "MakerBalances";
375
381
  data: MakerBalancesMessage;
382
+ } | {
383
+ type: "TokenCaps";
384
+ data: TokenCapsMessage;
385
+ } | {
386
+ type: "MyCaps";
387
+ data: MyCapsMessage;
376
388
  } | {
377
389
  type: "Subscriptions";
378
390
  data: SubscriptionsMessage;
@@ -454,6 +466,9 @@ export type ServerMessage = {
454
466
  } | {
455
467
  type: "StatsUpdate";
456
468
  data: StatsUpdateMessage;
469
+ } | {
470
+ type: "RfqSkipped";
471
+ data: RfqSkippedMessage;
457
472
  } | {
458
473
  type: "Pong";
459
474
  data: {
@@ -566,6 +581,46 @@ export type ServerError = {
566
581
  } | {
567
582
  type: "rate_limit";
568
583
  data: RateLimitReason;
584
+ } | {
585
+ type: "token_oi_cap_exceeded";
586
+ data: {
587
+ underlying_mint: string;
588
+ current: WsU64;
589
+ limit: WsU64;
590
+ };
591
+ } | {
592
+ type: "market_oi_cap_exceeded";
593
+ data: {
594
+ market_id: string;
595
+ current: WsU64;
596
+ limit: WsU64;
597
+ };
598
+ } | {
599
+ type: "maker_position_cap_exceeded";
600
+ data: {
601
+ current: WsU32;
602
+ limit: WsU32;
603
+ };
604
+ } | {
605
+ type: "maker_notional_cap_exceeded";
606
+ data: {
607
+ underlying_mint: string;
608
+ current: WsU64;
609
+ limit: WsU64;
610
+ };
611
+ } | {
612
+ type: "maker_insufficient_balance";
613
+ data: {
614
+ available: WsU64;
615
+ required: WsU64;
616
+ };
617
+ } | {
618
+ type: "quote_notional_cap_exceeded";
619
+ data: {
620
+ quote_mint: string;
621
+ current: WsU64;
622
+ limit: WsU64;
623
+ };
569
624
  } | {
570
625
  type: "internal_error";
571
626
  } | {
@@ -735,6 +790,68 @@ export type MakerMintBalance = {
735
790
  locked_as_collateral: WsU64;
736
791
  available: WsU64;
737
792
  };
793
+ export type GetTokenCapsMessage = {
794
+ request_id: RequestId;
795
+ include_markets?: boolean;
796
+ };
797
+ export type GetMyCapsMessage = {
798
+ request_id: RequestId;
799
+ };
800
+ export type RfqSkippedMessage = {
801
+ rfq_id: UuidString;
802
+ market_id: string;
803
+ quantity: WsU64;
804
+ reason: string;
805
+ };
806
+ export type QuoteCapInfo = {
807
+ quote_mint: string;
808
+ symbol: string;
809
+ current_notional: WsU64;
810
+ max_notional: WsU64;
811
+ utilization: number;
812
+ };
813
+ export type TokenCapsMessage = {
814
+ request_id: RequestId;
815
+ tokens: TokenCapInfo[];
816
+ markets?: MarketCapInfo[];
817
+ quotes?: QuoteCapInfo[];
818
+ };
819
+ export type MyCapsMessage = {
820
+ request_id: RequestId;
821
+ positions: MakerPositionCapInfo;
822
+ notional: MakerNotionalCapInfo[];
823
+ balances: MakerBalanceCapInfo[];
824
+ };
825
+ export type TokenCapInfo = {
826
+ underlying_mint: string;
827
+ symbol: string;
828
+ current_oi: WsU64;
829
+ max_oi: WsU64;
830
+ utilization: number;
831
+ };
832
+ export type MarketCapInfo = {
833
+ market_id: string;
834
+ current_oi: WsU64;
835
+ max_oi: WsU64;
836
+ utilization: number;
837
+ };
838
+ export type MakerPositionCapInfo = {
839
+ current: WsU32;
840
+ limit: WsU32;
841
+ };
842
+ export type MakerNotionalCapInfo = {
843
+ underlying_mint: string;
844
+ symbol: string;
845
+ current: WsU64;
846
+ limit: WsU64;
847
+ };
848
+ export type MakerBalanceCapInfo = {
849
+ mint: string;
850
+ symbol: string;
851
+ deposited: WsU64;
852
+ committed: WsU64;
853
+ available: WsU64;
854
+ };
738
855
  export type SubscriptionsMessage = {
739
856
  request_id: RequestId;
740
857
  channels: WsChannel[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acta-markets/ts-sdk",
3
- "version": "0.0.8-beta",
3
+ "version": "0.0.10-beta",
4
4
  "description": "TypeScript SDK for Acta Protocol",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",