@acta-markets/ts-sdk 0.0.19-beta → 0.0.21-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.
Files changed (47) hide show
  1. package/dist/chain/instructions.market.d.ts +0 -1
  2. package/dist/chain/instructions.market.js +1 -6
  3. package/dist/chain/instructions.oracle.d.ts +0 -3
  4. package/dist/chain/instructions.oracle.js +1 -5
  5. package/dist/chain/instructions.position.js +8 -16
  6. package/dist/chain/instructions.shared.d.ts +0 -1
  7. package/dist/chain/instructions.shared.js +0 -1
  8. package/dist/cjs/chain/instructions.market.js +0 -5
  9. package/dist/cjs/chain/instructions.oracle.js +0 -4
  10. package/dist/cjs/chain/instructions.position.js +8 -16
  11. package/dist/cjs/chain/instructions.shared.js +1 -2
  12. package/dist/cjs/generated/errors/actaContract.js +4 -1
  13. package/dist/cjs/generated/instructions/closeOracle.js +2 -13
  14. package/dist/cjs/generated/instructions/createMarket.js +1 -10
  15. package/dist/cjs/generated/instructions/createOracle.js +1 -4
  16. package/dist/cjs/generated/instructions/depositFundsToPosition.js +5 -11
  17. package/dist/cjs/generated/instructions/finalizeMarket.js +1 -9
  18. package/dist/cjs/generated/instructions/updateOraclePrice.js +2 -13
  19. package/dist/cjs/idl/acta_contract.json +10 -61
  20. package/dist/cjs/idl/hash.js +1 -1
  21. package/dist/cjs/ws/apy.js +4 -10
  22. package/dist/cjs/ws/apy.test.js +37 -1
  23. package/dist/cjs/ws/client.js +166 -15
  24. package/dist/generated/errors/actaContract.d.ts +3 -1
  25. package/dist/generated/errors/actaContract.js +3 -0
  26. package/dist/generated/instructions/closeOracle.d.ts +5 -10
  27. package/dist/generated/instructions/closeOracle.js +2 -13
  28. package/dist/generated/instructions/createMarket.d.ts +11 -21
  29. package/dist/generated/instructions/createMarket.js +1 -10
  30. package/dist/generated/instructions/createOracle.d.ts +7 -12
  31. package/dist/generated/instructions/createOracle.js +1 -4
  32. package/dist/generated/instructions/depositFundsToPosition.d.ts +9 -14
  33. package/dist/generated/instructions/depositFundsToPosition.js +5 -11
  34. package/dist/generated/instructions/finalizeMarket.d.ts +4 -9
  35. package/dist/generated/instructions/finalizeMarket.js +1 -9
  36. package/dist/generated/instructions/updateOraclePrice.d.ts +5 -10
  37. package/dist/generated/instructions/updateOraclePrice.js +2 -13
  38. package/dist/idl/acta_contract.json +10 -61
  39. package/dist/idl/hash.d.ts +1 -1
  40. package/dist/idl/hash.js +1 -1
  41. package/dist/ws/apy.d.ts +1 -1
  42. package/dist/ws/apy.js +4 -10
  43. package/dist/ws/apy.test.js +37 -1
  44. package/dist/ws/client.d.ts +60 -4
  45. package/dist/ws/client.js +166 -15
  46. package/dist/ws/types.d.ts +38 -2
  47. package/package.json +1 -1
@@ -344,7 +344,7 @@
344
344
  "isMut": false,
345
345
  "isSigner": false,
346
346
  "docs": [
347
- "Underlying SPL mint"
347
+ "Underlying SPL mint (used for PDA seed and decimals)"
348
348
  ]
349
349
  },
350
350
  {
@@ -352,23 +352,7 @@
352
352
  "isMut": false,
353
353
  "isSigner": false,
354
354
  "docs": [
355
- "Quote SPL mint"
356
- ]
357
- },
358
- {
359
- "name": "underlyingMintAcc",
360
- "isMut": false,
361
- "isSigner": false,
362
- "docs": [
363
- "Underlying mint account (for decimals)"
364
- ]
365
- },
366
- {
367
- "name": "quoteMintAcc",
368
- "isMut": false,
369
- "isSigner": false,
370
- "docs": [
371
- "Quote mint account (for decimals)"
355
+ "Quote SPL mint (used for PDA seed and decimals)"
372
356
  ]
373
357
  },
374
358
  {
@@ -617,14 +601,6 @@
617
601
  "docs": [
618
602
  "Quote oracle PDA"
619
603
  ]
620
- },
621
- {
622
- "name": "clockSysvar",
623
- "isMut": false,
624
- "isSigner": false,
625
- "docs": [
626
- "Clock sysvar account"
627
- ]
628
604
  }
629
605
  ],
630
606
  "args": [],
@@ -685,19 +661,11 @@
685
661
  ]
686
662
  },
687
663
  {
688
- "name": "underlyingTokenProgram",
689
- "isMut": false,
690
- "isSigner": false,
691
- "docs": [
692
- "Token program for underlying mint"
693
- ]
694
- },
695
- {
696
- "name": "quoteTokenProgram",
664
+ "name": "settlementTokenProgram",
697
665
  "isMut": false,
698
666
  "isSigner": false,
699
667
  "docs": [
700
- "Token program for quote mint"
668
+ "Token program for the settlement mint"
701
669
  ]
702
670
  }
703
671
  ],
@@ -1063,15 +1031,7 @@
1063
1031
  "isMut": false,
1064
1032
  "isSigner": false,
1065
1033
  "docs": [
1066
- "SPL mint this oracle prices"
1067
- ]
1068
- },
1069
- {
1070
- "name": "mintAcc",
1071
- "isMut": false,
1072
- "isSigner": false,
1073
- "docs": [
1074
- "Mint account (for decimals + token program owner)"
1034
+ "SPL mint this oracle prices (also used for decimals + token program owner)"
1075
1035
  ]
1076
1036
  },
1077
1037
  {
@@ -1129,14 +1089,6 @@
1129
1089
  "docs": [
1130
1090
  "Oracle PDA to update"
1131
1091
  ]
1132
- },
1133
- {
1134
- "name": "clockSysvar",
1135
- "isMut": false,
1136
- "isSigner": false,
1137
- "docs": [
1138
- "Clock sysvar account"
1139
- ]
1140
1092
  }
1141
1093
  ],
1142
1094
  "args": [
@@ -1251,14 +1203,6 @@
1251
1203
  "docs": [
1252
1204
  "Oracle PDA to close"
1253
1205
  ]
1254
- },
1255
- {
1256
- "name": "clockSysvar",
1257
- "isMut": false,
1258
- "isSigner": false,
1259
- "docs": [
1260
- "Clock sysvar account"
1261
- ]
1262
1206
  }
1263
1207
  ],
1264
1208
  "args": [],
@@ -2368,6 +2312,11 @@
2368
2312
  "code": 1076,
2369
2313
  "name": "MarketNotExpired",
2370
2314
  "msg": "Market has not expired yet"
2315
+ },
2316
+ {
2317
+ "code": 1077,
2318
+ "name": "OracleNotExpiredYet",
2319
+ "msg": "Oracle has not expired yet (cannot update price before expiry)"
2371
2320
  }
2372
2321
  ]
2373
2322
  }
@@ -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 = "8072bc43541635b8c359d8c0209c3ab63f6a264d6843997d20c9d6c9473130c9";
4
+ exports.ACTA_IDL_SHA256 = "2ccf0a77f682ff60b8201e2bca7f4bd026500a2fb9637d46dad7a8de3b2ee313";
@@ -58,17 +58,11 @@ function computeApyFromAmounts(args) {
58
58
  if (!Number.isFinite(premPU) || premPU < 0)
59
59
  throw new Error("invalid premiumPerUnderlying");
60
60
  const premiumNotional = qty * premPU;
61
- let collateralPerUnderlying;
62
- if (args.positionType === "cash_secured_put") {
63
- collateralPerUnderlying = args.strikePrice;
64
- }
65
- else {
66
- collateralPerUnderlying = args.spotPrice ?? NaN;
67
- }
61
+ // Collateral always valued at spot so APR is monotonic across strikes.
62
+ // On-chain collateral requirements are unchanged — display metric only.
63
+ const collateralPerUnderlying = args.spotPrice ?? NaN;
68
64
  if (!Number.isFinite(collateralPerUnderlying) || collateralPerUnderlying <= 0) {
69
- throw new Error(args.positionType === "covered_call"
70
- ? "spotPrice is required for covered_call yield"
71
- : "invalid strikePrice");
65
+ throw new Error("spotPrice is required for yield calculation");
72
66
  }
73
67
  const collateralNotional = qty * collateralPerUnderlying;
74
68
  const termYield = termYieldFromNotionals({ premiumNotional, collateralNotional });
@@ -7,7 +7,7 @@ describe("ws apy helpers", () => {
7
7
  positionType: "covered_call",
8
8
  underlyingAmount: 10,
9
9
  spotPrice: 150,
10
- strikePrice: 150, // not used for calls
10
+ strikePrice: 150, // not used for collateral, kept for API compat
11
11
  premiumPerUnderlying: 1.5,
12
12
  secondsToExpiry: 7 * 24 * 60 * 60,
13
13
  });
@@ -22,8 +22,44 @@ describe("ws apy helpers", () => {
22
22
  underlyingAmount: 10,
23
23
  grossPremiumPerUnit1e9: 1_500_000_000, // 1.5
24
24
  strike1e9: 150_000_000_000, // 150
25
+ spotPrice1e9: 150_000_000_000, // 150 (ATM)
25
26
  secondsToExpiry: 7 * 24 * 60 * 60,
26
27
  });
27
28
  expect(res.premiumNotional).toBeCloseTo(15, 10);
28
29
  });
30
+ it("put APR uses spot as collateral (not strike)", () => {
31
+ const spot = 150;
32
+ const strike = 120; // OTM put
33
+ const res = (0, apy_1.computeApyFromAmounts)({
34
+ positionType: "cash_secured_put",
35
+ underlyingAmount: 1,
36
+ spotPrice: spot,
37
+ strikePrice: strike,
38
+ premiumPerUnderlying: 1.5,
39
+ secondsToExpiry: 30 * 24 * 60 * 60,
40
+ });
41
+ // collateral should be spot-based, not strike-based
42
+ expect(res.collateralNotional).toBeCloseTo(spot, 10);
43
+ });
44
+ it("put APR is monotonically decreasing for OTM strikes", () => {
45
+ const spot1e9 = 150_000_000_000; // 150
46
+ const strikes = [140, 130, 120, 110].map(s => s * 1_000_000_000);
47
+ // Premiums decrease with OTM (roughly realistic)
48
+ const premiums = [5, 2.5, 1, 0.3].map(p => p * 1_000_000_000);
49
+ const aprs = strikes.map((strike, i) => {
50
+ const res = (0, apy_1.computeApyFromScaledPrices)({
51
+ positionType: "cash_secured_put",
52
+ underlyingAmount: 1,
53
+ grossPremiumPerUnit1e9: premiums[i],
54
+ strike1e9: strike,
55
+ spotPrice1e9: spot1e9,
56
+ secondsToExpiry: 30 * 24 * 60 * 60,
57
+ });
58
+ return res.apr;
59
+ });
60
+ // Each APR should be less than the previous
61
+ for (let i = 1; i < aprs.length; i++) {
62
+ expect(aprs[i]).toBeLessThan(aprs[i - 1]);
63
+ }
64
+ });
29
65
  });
@@ -110,8 +110,8 @@ class ActaWsClient extends TypedEventEmitter {
110
110
  pingTimer = null;
111
111
  shouldReconnect = true;
112
112
  subscribedChannels = new Set(["rfqs"]);
113
- subscribedMarkets = new Set();
114
- hasMarketScope = false;
113
+ underlyingMintScope = null; // null = all
114
+ quoteMintScope = null; // null = all
115
115
  marketDescriptorsByMarket = new Map();
116
116
  state = {
117
117
  stats: null,
@@ -339,6 +339,70 @@ class ActaWsClient extends TypedEventEmitter {
339
339
  });
340
340
  return requestId;
341
341
  }
342
+ /** Maker-only: get balances per deposited token (total, locked, available). */
343
+ getMakerBalances() {
344
+ this.ensureAuthenticated();
345
+ const requestId = this.nextRequestId();
346
+ this.send({
347
+ type: "GetMakerBalances",
348
+ data: { request_id: requestId },
349
+ });
350
+ return requestId;
351
+ }
352
+ /** Maker-only: get open positions with optional filters. */
353
+ getMakerPositions(args) {
354
+ this.ensureAuthenticated();
355
+ const requestId = this.nextRequestId();
356
+ const data = {
357
+ request_id: requestId,
358
+ ...args,
359
+ };
360
+ this.send({ type: "GetMakerPositions", data });
361
+ return requestId;
362
+ }
363
+ /** Maker-only: get trade history with keyset pagination. */
364
+ getMyTrades(args) {
365
+ this.ensureAuthenticated();
366
+ const requestId = this.nextRequestId();
367
+ const data = {
368
+ request_id: requestId,
369
+ ...args,
370
+ };
371
+ this.send({ type: "GetMyTrades", data });
372
+ return requestId;
373
+ }
374
+ /** Maker-only: get position, notional, and balance caps. */
375
+ getMyCaps() {
376
+ this.ensureAuthenticated();
377
+ const requestId = this.nextRequestId();
378
+ this.send({
379
+ type: "GetMyCaps",
380
+ data: { request_id: requestId },
381
+ });
382
+ return requestId;
383
+ }
384
+ /** Maker-only: get markets where maker has deposits, with optional filters and stats. */
385
+ getMarketsForMaker(args) {
386
+ this.ensureAuthenticated();
387
+ const requestId = this.nextRequestId();
388
+ const data = {
389
+ request_id: requestId,
390
+ ...args,
391
+ };
392
+ this.send({ type: "GetMarketsForMaker", data });
393
+ return requestId;
394
+ }
395
+ /** Maker-only: get submitted quotes with status. */
396
+ getMyQuotes(args) {
397
+ this.ensureAuthenticated();
398
+ const requestId = this.nextRequestId();
399
+ const data = {
400
+ request_id: requestId,
401
+ active_only: args?.active_only ?? true,
402
+ };
403
+ this.send({ type: "GetMyQuotes", data });
404
+ return requestId;
405
+ }
342
406
  logout() {
343
407
  this.send({ type: "Logout" });
344
408
  }
@@ -395,21 +459,25 @@ class ActaWsClient extends TypedEventEmitter {
395
459
  });
396
460
  return requestId;
397
461
  }
398
- subscribe(channels, markets) {
462
+ subscribe(channels, opts) {
399
463
  this.ensureAuthenticated();
400
464
  const request_id = this.nextRequestId();
401
465
  for (const c of channels)
402
466
  this.subscribedChannels.add(c);
403
- if (markets) {
404
- this.hasMarketScope = true;
405
- this.subscribedMarkets = new Set(markets);
467
+ if (opts?.underlying_mints) {
468
+ this.underlyingMintScope = new Set(opts.underlying_mints);
406
469
  }
407
- this.send({
408
- type: "Subscribe",
409
- data: this.hasMarketScope
410
- ? { request_id, channels, markets: Array.from(this.subscribedMarkets) }
411
- : { request_id, channels },
412
- });
470
+ if (opts?.quote_mints) {
471
+ this.quoteMintScope = new Set(opts.quote_mints);
472
+ }
473
+ const data = { request_id, channels };
474
+ if (this.underlyingMintScope) {
475
+ data.underlying_mints = Array.from(this.underlyingMintScope);
476
+ }
477
+ if (this.quoteMintScope) {
478
+ data.quote_mints = Array.from(this.quoteMintScope);
479
+ }
480
+ this.send({ type: "Subscribe", data });
413
481
  return request_id;
414
482
  }
415
483
  unsubscribe(channels) {
@@ -423,6 +491,58 @@ class ActaWsClient extends TypedEventEmitter {
423
491
  });
424
492
  return request_id;
425
493
  }
494
+ addMints(opts) {
495
+ this.ensureAuthenticated();
496
+ const request_id = this.nextRequestId();
497
+ if (opts.underlying_mints) {
498
+ if (!this.underlyingMintScope)
499
+ this.underlyingMintScope = new Set();
500
+ for (const m of opts.underlying_mints)
501
+ this.underlyingMintScope.add(m);
502
+ }
503
+ if (opts.quote_mints) {
504
+ if (!this.quoteMintScope)
505
+ this.quoteMintScope = new Set();
506
+ for (const m of opts.quote_mints)
507
+ this.quoteMintScope.add(m);
508
+ }
509
+ this.send({ type: "AddMints", data: { request_id, ...opts } });
510
+ return request_id;
511
+ }
512
+ removeMints(opts) {
513
+ this.ensureAuthenticated();
514
+ const request_id = this.nextRequestId();
515
+ if (opts.underlying_mints && this.underlyingMintScope) {
516
+ for (const m of opts.underlying_mints)
517
+ this.underlyingMintScope.delete(m);
518
+ if (this.underlyingMintScope.size === 0)
519
+ this.underlyingMintScope = null;
520
+ }
521
+ if (opts.quote_mints && this.quoteMintScope) {
522
+ for (const m of opts.quote_mints)
523
+ this.quoteMintScope.delete(m);
524
+ if (this.quoteMintScope.size === 0)
525
+ this.quoteMintScope = null;
526
+ }
527
+ this.send({ type: "RemoveMints", data: { request_id, ...opts } });
528
+ return request_id;
529
+ }
530
+ addChannels(channels) {
531
+ this.ensureAuthenticated();
532
+ const request_id = this.nextRequestId();
533
+ for (const c of channels)
534
+ this.subscribedChannels.add(c);
535
+ this.send({ type: "AddChannels", data: { request_id, channels } });
536
+ return request_id;
537
+ }
538
+ removeChannels(channels) {
539
+ this.ensureAuthenticated();
540
+ const request_id = this.nextRequestId();
541
+ for (const c of channels)
542
+ this.subscribedChannels.delete(c);
543
+ this.send({ type: "RemoveChannels", data: { request_id, channels } });
544
+ return request_id;
545
+ }
426
546
  ping() {
427
547
  if (this.ws?.readyState === WS_OPEN) {
428
548
  this.send({ type: "Ping" });
@@ -573,6 +693,21 @@ class ActaWsClient extends TypedEventEmitter {
573
693
  case "MyCaps":
574
694
  this.emit("myCaps", message.data);
575
695
  break;
696
+ case "MakerBalances":
697
+ this.emit("makerBalances", message.data);
698
+ break;
699
+ case "MakerPositions":
700
+ this.emit("makerPositions", message.data);
701
+ break;
702
+ case "MyTrades":
703
+ this.emit("myTrades", message.data);
704
+ break;
705
+ case "MakerMarkets":
706
+ this.emit("makerMarkets", message.data);
707
+ break;
708
+ case "MyQuotes":
709
+ this.emit("myQuotes", message.data);
710
+ break;
576
711
  case "MyActiveRfqs":
577
712
  this.handleMyActiveRfqs(message.data);
578
713
  break;
@@ -730,6 +865,18 @@ class ActaWsClient extends TypedEventEmitter {
730
865
  case "UnsubscribeAck":
731
866
  this.emit("unsubscribeAck", message.data);
732
867
  break;
868
+ case "SubscriptionUpdated":
869
+ {
870
+ const d = message.data;
871
+ // Sync local state from the server's authoritative response.
872
+ this.subscribedChannels = new Set(d.channels);
873
+ this.underlyingMintScope =
874
+ d.underlying_mints != null ? new Set(d.underlying_mints) : null;
875
+ this.quoteMintScope =
876
+ d.quote_mints != null ? new Set(d.quote_mints) : null;
877
+ this.emit("subscriptionUpdated", d);
878
+ }
879
+ break;
733
880
  }
734
881
  }
735
882
  /** Taker-only: request current indicative prices for a market + position_type. */
@@ -815,9 +962,13 @@ class ActaWsClient extends TypedEventEmitter {
815
962
  if (this.subscribedChannels.size > 0) {
816
963
  const channels = Array.from(this.subscribedChannels);
817
964
  const request_id = this.nextRequestId();
818
- const data = this.hasMarketScope
819
- ? { request_id, channels, markets: Array.from(this.subscribedMarkets) }
820
- : { request_id, channels };
965
+ const data = { request_id, channels };
966
+ if (this.underlyingMintScope) {
967
+ data.underlying_mints = Array.from(this.underlyingMintScope);
968
+ }
969
+ if (this.quoteMintScope) {
970
+ data.quote_mints = Array.from(this.quoteMintScope);
971
+ }
821
972
  this.send({ type: "Subscribe", data });
822
973
  }
823
974
  }
@@ -96,7 +96,9 @@ export declare const ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = 1074;
96
96
  export declare const ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 1075;
97
97
  /** MarketNotExpired: Market has not expired yet */
98
98
  export declare const ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = 1076;
99
- export type ActaContractError = typeof ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED | typeof ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED | typeof ACTA_CONTRACT_ERROR__CANNOT_LIQUIDATE_FUNDED | 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_EXPIRED | 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;
99
+ /** OracleNotExpiredYet: Oracle has not expired yet (cannot update price before expiry) */
100
+ export declare const ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET = 1077;
101
+ export type ActaContractError = typeof ACTA_CONTRACT_ERROR__ACCOUNT_ALREADY_INITIALIZED | typeof ACTA_CONTRACT_ERROR__ACCOUNT_NOT_INITIALIZED | typeof ACTA_CONTRACT_ERROR__CANNOT_LIQUIDATE_FUNDED | 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_EXPIRED | 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_NOT_EXPIRED_YET | 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;
100
102
  export declare function getActaContractErrorMessage(code: ActaContractError): string;
101
103
  export declare function isActaContractError<TProgramErrorCode extends ActaContractError>(error: unknown, transactionMessage: {
102
104
  instructions: Record<number, {
@@ -97,6 +97,8 @@ export const ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS = 0x432; // 1074
97
97
  export const ACTA_CONTRACT_ERROR__DUPLICATE_ACCOUNT = 0x433; // 1075
98
98
  /** MarketNotExpired: Market has not expired yet */
99
99
  export const ACTA_CONTRACT_ERROR__MARKET_NOT_EXPIRED = 0x434; // 1076
100
+ /** OracleNotExpiredYet: Oracle has not expired yet (cannot update price before expiry) */
101
+ export const ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET = 0x435; // 1077
100
102
  let actaContractErrorMessages;
101
103
  if (process.env.NODE_ENV !== "production") {
102
104
  actaContractErrorMessages = {
@@ -133,6 +135,7 @@ if (process.env.NODE_ENV !== "production") {
133
135
  [ACTA_CONTRACT_ERROR__ORACLE_HAS_ACTIVE_MARKETS]: `Oracle is still linked to active markets`,
134
136
  [ACTA_CONTRACT_ERROR__ORACLE_INACTIVE]: `Oracle inactive`,
135
137
  [ACTA_CONTRACT_ERROR__ORACLE_INVALID_PRICE]: `Oracle price invalid (zero or negative)`,
138
+ [ACTA_CONTRACT_ERROR__ORACLE_NOT_EXPIRED_YET]: `Oracle has not expired yet (cannot update price before expiry)`,
136
139
  [ACTA_CONTRACT_ERROR__ORACLE_SOURCE_LOCKED]: `Oracle source fields are locked after first update`,
137
140
  [ACTA_CONTRACT_ERROR__ORACLE_STALE]: `Oracle price is stale (updated_at before expiry)`,
138
141
  [ACTA_CONTRACT_ERROR__POSITION_ALREADY_FUNDED]: `Position already funded by maker`,
@@ -5,14 +5,13 @@
5
5
  *
6
6
  * @see https://github.com/codama-idl/codama
7
7
  */
8
- import { type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from "@solana/kit";
8
+ import { type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from "@solana/kit";
9
9
  import { ACTA_CONTRACT_PROGRAM_ADDRESS } from "../programs";
10
10
  export declare const CLOSE_ORACLE_DISCRIMINATOR = 19;
11
11
  export declare function getCloseOracleDiscriminatorBytes(): ReadonlyUint8Array;
12
- export type CloseOracleInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountSigner extends string | AccountMeta<string> = string, TAccountOraclePda extends string | AccountMeta<string> = string, TAccountClockSysvar extends string | AccountMeta<string> = "SysvarC1ock11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
12
+ export type CloseOracleInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountSigner extends string | AccountMeta<string> = string, TAccountOraclePda extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
13
13
  TAccountSigner extends string ? WritableSignerAccount<TAccountSigner> & AccountSignerMeta<TAccountSigner> : TAccountSigner,
14
14
  TAccountOraclePda extends string ? WritableAccount<TAccountOraclePda> : TAccountOraclePda,
15
- TAccountClockSysvar extends string ? ReadonlyAccount<TAccountClockSysvar> : TAccountClockSysvar,
16
15
  ...TRemainingAccounts
17
16
  ]>;
18
17
  export type CloseOracleInstructionData = {
@@ -22,17 +21,15 @@ export type CloseOracleInstructionDataArgs = {};
22
21
  export declare function getCloseOracleInstructionDataEncoder(): FixedSizeEncoder<CloseOracleInstructionDataArgs>;
23
22
  export declare function getCloseOracleInstructionDataDecoder(): FixedSizeDecoder<CloseOracleInstructionData>;
24
23
  export declare function getCloseOracleInstructionDataCodec(): FixedSizeCodec<CloseOracleInstructionDataArgs, CloseOracleInstructionData>;
25
- export type CloseOracleInput<TAccountSigner extends string = string, TAccountOraclePda extends string = string, TAccountClockSysvar extends string = string> = {
24
+ export type CloseOracleInput<TAccountSigner extends string = string, TAccountOraclePda extends string = string> = {
26
25
  /** Protocol admin authority */
27
26
  signer: TransactionSigner<TAccountSigner>;
28
27
  /** Oracle PDA to close */
29
28
  oraclePda: Address<TAccountOraclePda>;
30
- /** Clock sysvar account */
31
- clockSysvar?: Address<TAccountClockSysvar>;
32
29
  };
33
- export declare function getCloseOracleInstruction<TAccountSigner extends string, TAccountOraclePda extends string, TAccountClockSysvar extends string, TProgramAddress extends Address = typeof ACTA_CONTRACT_PROGRAM_ADDRESS>(input: CloseOracleInput<TAccountSigner, TAccountOraclePda, TAccountClockSysvar>, config?: {
30
+ export declare function getCloseOracleInstruction<TAccountSigner extends string, TAccountOraclePda extends string, TProgramAddress extends Address = typeof ACTA_CONTRACT_PROGRAM_ADDRESS>(input: CloseOracleInput<TAccountSigner, TAccountOraclePda>, config?: {
34
31
  programAddress?: TProgramAddress;
35
- }): CloseOracleInstruction<TProgramAddress, TAccountSigner, TAccountOraclePda, TAccountClockSysvar>;
32
+ }): CloseOracleInstruction<TProgramAddress, TAccountSigner, TAccountOraclePda>;
36
33
  export type ParsedCloseOracleInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = {
37
34
  programAddress: Address<TProgram>;
38
35
  accounts: {
@@ -40,8 +37,6 @@ export type ParsedCloseOracleInstruction<TProgram extends string = typeof ACTA_C
40
37
  signer: TAccountMetas[0];
41
38
  /** Oracle PDA to close */
42
39
  oraclePda: TAccountMetas[1];
43
- /** Clock sysvar account */
44
- clockSysvar: TAccountMetas[2];
45
40
  };
46
41
  data: CloseOracleInstructionData;
47
42
  };
@@ -28,27 +28,20 @@ export function getCloseOracleInstruction(input, config) {
28
28
  const originalAccounts = {
29
29
  signer: { value: input.signer ?? null, isWritable: true },
30
30
  oraclePda: { value: input.oraclePda ?? null, isWritable: true },
31
- clockSysvar: { value: input.clockSysvar ?? null, isWritable: false },
32
31
  };
33
32
  const accounts = originalAccounts;
34
- // Resolve default values.
35
- if (!accounts.clockSysvar.value) {
36
- accounts.clockSysvar.value =
37
- "SysvarC1ock11111111111111111111111111111111";
38
- }
39
33
  const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
40
34
  return Object.freeze({
41
35
  accounts: [
42
36
  getAccountMeta(accounts.signer),
43
37
  getAccountMeta(accounts.oraclePda),
44
- getAccountMeta(accounts.clockSysvar),
45
38
  ],
46
39
  data: getCloseOracleInstructionDataEncoder().encode({}),
47
40
  programAddress,
48
41
  });
49
42
  }
50
43
  export function parseCloseOracleInstruction(instruction) {
51
- if (instruction.accounts.length < 3) {
44
+ if (instruction.accounts.length < 2) {
52
45
  // TODO: Coded error.
53
46
  throw new Error("Not enough accounts");
54
47
  }
@@ -60,11 +53,7 @@ export function parseCloseOracleInstruction(instruction) {
60
53
  };
61
54
  return {
62
55
  programAddress: instruction.programAddress,
63
- accounts: {
64
- signer: getNextAccount(),
65
- oraclePda: getNextAccount(),
66
- clockSysvar: getNextAccount(),
67
- },
56
+ accounts: { signer: getNextAccount(), oraclePda: getNextAccount() },
68
57
  data: getCloseOracleInstructionDataDecoder().decode(instruction.data),
69
58
  };
70
59
  }
@@ -9,14 +9,12 @@ import { type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeC
9
9
  import { ACTA_CONTRACT_PROGRAM_ADDRESS } from "../programs";
10
10
  export declare const CREATE_MARKET_DISCRIMINATOR = 6;
11
11
  export declare function getCreateMarketDiscriminatorBytes(): ReadonlyUint8Array;
12
- export type CreateMarketInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountAdmin extends string | AccountMeta<string> = string, TAccountConfigPda extends string | AccountMeta<string> = string, TAccountMarketPda extends string | AccountMeta<string> = string, TAccountUnderlyingMint extends string | AccountMeta<string> = string, TAccountQuoteMint extends string | AccountMeta<string> = string, TAccountUnderlyingMintAcc extends string | AccountMeta<string> = string, TAccountQuoteMintAcc extends string | AccountMeta<string> = string, TAccountOracleUnderlying extends string | AccountMeta<string> = string, TAccountOracleQuote extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
12
+ export type CreateMarketInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountAdmin extends string | AccountMeta<string> = string, TAccountConfigPda extends string | AccountMeta<string> = string, TAccountMarketPda extends string | AccountMeta<string> = string, TAccountUnderlyingMint extends string | AccountMeta<string> = string, TAccountQuoteMint extends string | AccountMeta<string> = string, TAccountOracleUnderlying extends string | AccountMeta<string> = string, TAccountOracleQuote extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
13
13
  TAccountAdmin extends string ? WritableSignerAccount<TAccountAdmin> & AccountSignerMeta<TAccountAdmin> : TAccountAdmin,
14
14
  TAccountConfigPda extends string ? ReadonlyAccount<TAccountConfigPda> : TAccountConfigPda,
15
15
  TAccountMarketPda extends string ? WritableAccount<TAccountMarketPda> : TAccountMarketPda,
16
16
  TAccountUnderlyingMint extends string ? ReadonlyAccount<TAccountUnderlyingMint> : TAccountUnderlyingMint,
17
17
  TAccountQuoteMint extends string ? ReadonlyAccount<TAccountQuoteMint> : TAccountQuoteMint,
18
- TAccountUnderlyingMintAcc extends string ? ReadonlyAccount<TAccountUnderlyingMintAcc> : TAccountUnderlyingMintAcc,
19
- TAccountQuoteMintAcc extends string ? ReadonlyAccount<TAccountQuoteMintAcc> : TAccountQuoteMintAcc,
20
18
  TAccountOracleUnderlying extends string ? WritableAccount<TAccountOracleUnderlying> : TAccountOracleUnderlying,
21
19
  TAccountOracleQuote extends string ? WritableAccount<TAccountOracleQuote> : TAccountOracleQuote,
22
20
  TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram,
@@ -34,21 +32,17 @@ export type CreateMarketInstructionDataArgs = {
34
32
  export declare function getCreateMarketInstructionDataEncoder(): FixedSizeEncoder<CreateMarketInstructionDataArgs>;
35
33
  export declare function getCreateMarketInstructionDataDecoder(): FixedSizeDecoder<CreateMarketInstructionData>;
36
34
  export declare function getCreateMarketInstructionDataCodec(): FixedSizeCodec<CreateMarketInstructionDataArgs, CreateMarketInstructionData>;
37
- export type CreateMarketInput<TAccountAdmin extends string = string, TAccountConfigPda extends string = string, TAccountMarketPda extends string = string, TAccountUnderlyingMint extends string = string, TAccountQuoteMint extends string = string, TAccountUnderlyingMintAcc extends string = string, TAccountQuoteMintAcc extends string = string, TAccountOracleUnderlying extends string = string, TAccountOracleQuote extends string = string, TAccountSystemProgram extends string = string> = {
35
+ export type CreateMarketInput<TAccountAdmin extends string = string, TAccountConfigPda extends string = string, TAccountMarketPda extends string = string, TAccountUnderlyingMint extends string = string, TAccountQuoteMint extends string = string, TAccountOracleUnderlying extends string = string, TAccountOracleQuote extends string = string, TAccountSystemProgram extends string = string> = {
38
36
  /** Protocol admin authority */
39
37
  admin: TransactionSigner<TAccountAdmin>;
40
38
  /** Config PDA for admin verification */
41
39
  configPda: Address<TAccountConfigPda>;
42
40
  /** Market PDA to create */
43
41
  marketPda: Address<TAccountMarketPda>;
44
- /** Underlying SPL mint */
42
+ /** Underlying SPL mint (used for PDA seed and decimals) */
45
43
  underlyingMint: Address<TAccountUnderlyingMint>;
46
- /** Quote SPL mint */
44
+ /** Quote SPL mint (used for PDA seed and decimals) */
47
45
  quoteMint: Address<TAccountQuoteMint>;
48
- /** Underlying mint account (for decimals) */
49
- underlyingMintAcc: Address<TAccountUnderlyingMintAcc>;
50
- /** Quote mint account (for decimals) */
51
- quoteMintAcc: Address<TAccountQuoteMintAcc>;
52
46
  /** Underlying oracle PDA */
53
47
  oracleUnderlying: Address<TAccountOracleUnderlying>;
54
48
  /** Quote oracle PDA */
@@ -58,9 +52,9 @@ export type CreateMarketInput<TAccountAdmin extends string = string, TAccountCon
58
52
  expiryTs: CreateMarketInstructionDataArgs["expiryTs"];
59
53
  isPut: CreateMarketInstructionDataArgs["isPut"];
60
54
  };
61
- export declare function getCreateMarketInstruction<TAccountAdmin extends string, TAccountConfigPda extends string, TAccountMarketPda extends string, TAccountUnderlyingMint extends string, TAccountQuoteMint extends string, TAccountUnderlyingMintAcc extends string, TAccountQuoteMintAcc extends string, TAccountOracleUnderlying extends string, TAccountOracleQuote extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof ACTA_CONTRACT_PROGRAM_ADDRESS>(input: CreateMarketInput<TAccountAdmin, TAccountConfigPda, TAccountMarketPda, TAccountUnderlyingMint, TAccountQuoteMint, TAccountUnderlyingMintAcc, TAccountQuoteMintAcc, TAccountOracleUnderlying, TAccountOracleQuote, TAccountSystemProgram>, config?: {
55
+ export declare function getCreateMarketInstruction<TAccountAdmin extends string, TAccountConfigPda extends string, TAccountMarketPda extends string, TAccountUnderlyingMint extends string, TAccountQuoteMint extends string, TAccountOracleUnderlying extends string, TAccountOracleQuote extends string, TAccountSystemProgram extends string, TProgramAddress extends Address = typeof ACTA_CONTRACT_PROGRAM_ADDRESS>(input: CreateMarketInput<TAccountAdmin, TAccountConfigPda, TAccountMarketPda, TAccountUnderlyingMint, TAccountQuoteMint, TAccountOracleUnderlying, TAccountOracleQuote, TAccountSystemProgram>, config?: {
62
56
  programAddress?: TProgramAddress;
63
- }): CreateMarketInstruction<TProgramAddress, TAccountAdmin, TAccountConfigPda, TAccountMarketPda, TAccountUnderlyingMint, TAccountQuoteMint, TAccountUnderlyingMintAcc, TAccountQuoteMintAcc, TAccountOracleUnderlying, TAccountOracleQuote, TAccountSystemProgram>;
57
+ }): CreateMarketInstruction<TProgramAddress, TAccountAdmin, TAccountConfigPda, TAccountMarketPda, TAccountUnderlyingMint, TAccountQuoteMint, TAccountOracleUnderlying, TAccountOracleQuote, TAccountSystemProgram>;
64
58
  export type ParsedCreateMarketInstruction<TProgram extends string = typeof ACTA_CONTRACT_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = {
65
59
  programAddress: Address<TProgram>;
66
60
  accounts: {
@@ -70,20 +64,16 @@ export type ParsedCreateMarketInstruction<TProgram extends string = typeof ACTA_
70
64
  configPda: TAccountMetas[1];
71
65
  /** Market PDA to create */
72
66
  marketPda: TAccountMetas[2];
73
- /** Underlying SPL mint */
67
+ /** Underlying SPL mint (used for PDA seed and decimals) */
74
68
  underlyingMint: TAccountMetas[3];
75
- /** Quote SPL mint */
69
+ /** Quote SPL mint (used for PDA seed and decimals) */
76
70
  quoteMint: TAccountMetas[4];
77
- /** Underlying mint account (for decimals) */
78
- underlyingMintAcc: TAccountMetas[5];
79
- /** Quote mint account (for decimals) */
80
- quoteMintAcc: TAccountMetas[6];
81
71
  /** Underlying oracle PDA */
82
- oracleUnderlying: TAccountMetas[7];
72
+ oracleUnderlying: TAccountMetas[5];
83
73
  /** Quote oracle PDA */
84
- oracleQuote: TAccountMetas[8];
74
+ oracleQuote: TAccountMetas[6];
85
75
  /** System program */
86
- systemProgram: TAccountMetas[9];
76
+ systemProgram: TAccountMetas[7];
87
77
  };
88
78
  data: CreateMarketInstructionData;
89
79
  };