@acta-markets/ts-sdk 0.0.9-beta → 0.0.11-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.
- package/dist/chain/fetch.test.js +2 -2
- package/dist/cjs/chain/fetch.test.js +2 -2
- package/dist/cjs/events.test.js +2 -0
- package/dist/cjs/generated/accounts/position.js +3 -3
- package/dist/cjs/generated/errors/actaContract.js +4 -1
- package/dist/cjs/idl/acta_contract.json +6 -1
- package/dist/cjs/idl/hash.js +1 -1
- package/dist/cjs/ws/client.js +17 -0
- package/dist/events.test.js +2 -0
- package/dist/generated/accounts/position.js +3 -3
- package/dist/generated/errors/actaContract.d.ts +3 -1
- package/dist/generated/errors/actaContract.js +3 -0
- package/dist/idl/acta_contract.json +6 -1
- package/dist/idl/hash.d.ts +1 -1
- package/dist/idl/hash.js +1 -1
- package/dist/ws/client.d.ts +5 -1
- package/dist/ws/client.js +17 -0
- package/dist/ws/types.d.ts +117 -0
- package/package.json +1 -1
package/dist/chain/fetch.test.js
CHANGED
|
@@ -102,7 +102,7 @@ describe("fetch offsets and order encode", () => {
|
|
|
102
102
|
totalPremium: 0x9999888877776666n,
|
|
103
103
|
orderId: new Uint8Array(32).fill(0x88),
|
|
104
104
|
createdAt: 0n,
|
|
105
|
-
reserved: Array(
|
|
105
|
+
reserved: Array(32).fill(0n),
|
|
106
106
|
});
|
|
107
107
|
expect(positionData.length).toBe(getPositionSize());
|
|
108
108
|
expect(positionData[POSITION_OFFSET_STATUS]).toBe(3);
|
|
@@ -181,7 +181,7 @@ describe("fetch offsets and order encode", () => {
|
|
|
181
181
|
totalPremium: 1n,
|
|
182
182
|
orderId: new Uint8Array(32).fill(0x11),
|
|
183
183
|
createdAt: 0n,
|
|
184
|
-
reserved: Array(
|
|
184
|
+
reserved: Array(32).fill(0n),
|
|
185
185
|
});
|
|
186
186
|
expect(() => decodeMarketAccount(Buffer.from(positionData))).toThrow("Invalid Market account discriminator");
|
|
187
187
|
expect(() => decodeMarketAccount(Buffer.alloc(8))).toThrow("Invalid Market account size");
|
|
@@ -104,7 +104,7 @@ describe("fetch offsets and order encode", () => {
|
|
|
104
104
|
totalPremium: 0x9999888877776666n,
|
|
105
105
|
orderId: new Uint8Array(32).fill(0x88),
|
|
106
106
|
createdAt: 0n,
|
|
107
|
-
reserved: Array(
|
|
107
|
+
reserved: Array(32).fill(0n),
|
|
108
108
|
});
|
|
109
109
|
expect(positionData.length).toBe((0, position_1.getPositionSize)());
|
|
110
110
|
expect(positionData[fetch_1.POSITION_OFFSET_STATUS]).toBe(3);
|
|
@@ -183,7 +183,7 @@ describe("fetch offsets and order encode", () => {
|
|
|
183
183
|
totalPremium: 1n,
|
|
184
184
|
orderId: new Uint8Array(32).fill(0x11),
|
|
185
185
|
createdAt: 0n,
|
|
186
|
-
reserved: Array(
|
|
186
|
+
reserved: Array(32).fill(0n),
|
|
187
187
|
});
|
|
188
188
|
expect(() => (0, fetch_1.decodeMarketAccount)(buffer_1.Buffer.from(positionData))).toThrow("Invalid Market account discriminator");
|
|
189
189
|
expect(() => (0, fetch_1.decodeMarketAccount)(buffer_1.Buffer.alloc(8))).toThrow("Invalid Market account size");
|
package/dist/cjs/events.test.js
CHANGED
|
@@ -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
|
|
@@ -36,7 +36,7 @@ function getPositionEncoder() {
|
|
|
36
36
|
["totalPremium", (0, kit_1.getU64Encoder)()],
|
|
37
37
|
["orderId", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 32)],
|
|
38
38
|
["createdAt", (0, kit_1.getU64Encoder)()],
|
|
39
|
-
["reserved", (0, kit_1.getArrayEncoder)((0, kit_1.getU64Encoder)(), { size:
|
|
39
|
+
["reserved", (0, kit_1.getArrayEncoder)((0, kit_1.getU64Encoder)(), { size: 32 })],
|
|
40
40
|
]);
|
|
41
41
|
}
|
|
42
42
|
/** Gets the decoder for {@link Position} account data. */
|
|
@@ -58,7 +58,7 @@ function getPositionDecoder() {
|
|
|
58
58
|
["totalPremium", (0, kit_1.getU64Decoder)()],
|
|
59
59
|
["orderId", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 32)],
|
|
60
60
|
["createdAt", (0, kit_1.getU64Decoder)()],
|
|
61
|
-
["reserved", (0, kit_1.getArrayDecoder)((0, kit_1.getU64Decoder)(), { size:
|
|
61
|
+
["reserved", (0, kit_1.getArrayDecoder)((0, kit_1.getU64Decoder)(), { size: 32 })],
|
|
62
62
|
]);
|
|
63
63
|
}
|
|
64
64
|
/** Gets the codec for {@link Position} account data. */
|
|
@@ -87,5 +87,5 @@ async function fetchAllMaybePosition(rpc, addresses, config) {
|
|
|
87
87
|
return maybeAccounts.map((maybeAccount) => decodePosition(maybeAccount));
|
|
88
88
|
}
|
|
89
89
|
function getPositionSize() {
|
|
90
|
-
return
|
|
90
|
+
return 424;
|
|
91
91
|
}
|
|
@@ -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`,
|
|
@@ -1605,7 +1605,7 @@
|
|
|
1605
1605
|
"type": {
|
|
1606
1606
|
"array": [
|
|
1607
1607
|
"u64",
|
|
1608
|
-
|
|
1608
|
+
32
|
|
1609
1609
|
]
|
|
1610
1610
|
}
|
|
1611
1611
|
}
|
|
@@ -2349,6 +2349,11 @@
|
|
|
2349
2349
|
"code": 1074,
|
|
2350
2350
|
"name": "OracleHasActiveMarkets",
|
|
2351
2351
|
"msg": "Oracle is still linked to active markets"
|
|
2352
|
+
},
|
|
2353
|
+
{
|
|
2354
|
+
"code": 1075,
|
|
2355
|
+
"name": "DuplicateAccount",
|
|
2356
|
+
"msg": "Duplicate account passed to instruction"
|
|
2352
2357
|
}
|
|
2353
2358
|
]
|
|
2354
2359
|
}
|
package/dist/cjs/idl/hash.js
CHANGED
|
@@ -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 = "
|
|
4
|
+
exports.ACTA_IDL_SHA256 = "a86d779d49761e2979103c9ebd3eeb10f85fc9c4fc5848d78d11326e3eedab83";
|
package/dist/cjs/ws/client.js
CHANGED
|
@@ -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
|
}
|
|
@@ -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":
|
package/dist/events.test.js
CHANGED
|
@@ -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
|
|
@@ -25,7 +25,7 @@ export function getPositionEncoder() {
|
|
|
25
25
|
["totalPremium", getU64Encoder()],
|
|
26
26
|
["orderId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
27
27
|
["createdAt", getU64Encoder()],
|
|
28
|
-
["reserved", getArrayEncoder(getU64Encoder(), { size:
|
|
28
|
+
["reserved", getArrayEncoder(getU64Encoder(), { size: 32 })],
|
|
29
29
|
]);
|
|
30
30
|
}
|
|
31
31
|
/** Gets the decoder for {@link Position} account data. */
|
|
@@ -47,7 +47,7 @@ export function getPositionDecoder() {
|
|
|
47
47
|
["totalPremium", getU64Decoder()],
|
|
48
48
|
["orderId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
49
49
|
["createdAt", getU64Decoder()],
|
|
50
|
-
["reserved", getArrayDecoder(getU64Decoder(), { size:
|
|
50
|
+
["reserved", getArrayDecoder(getU64Decoder(), { size: 32 })],
|
|
51
51
|
]);
|
|
52
52
|
}
|
|
53
53
|
/** Gets the codec for {@link Position} account data. */
|
|
@@ -76,5 +76,5 @@ export async function fetchAllMaybePosition(rpc, addresses, config) {
|
|
|
76
76
|
return maybeAccounts.map((maybeAccount) => decodePosition(maybeAccount));
|
|
77
77
|
}
|
|
78
78
|
export function getPositionSize() {
|
|
79
|
-
return
|
|
79
|
+
return 424;
|
|
80
80
|
}
|
|
@@ -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
|
-
|
|
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`,
|
|
@@ -1605,7 +1605,7 @@
|
|
|
1605
1605
|
"type": {
|
|
1606
1606
|
"array": [
|
|
1607
1607
|
"u64",
|
|
1608
|
-
|
|
1608
|
+
32
|
|
1609
1609
|
]
|
|
1610
1610
|
}
|
|
1611
1611
|
}
|
|
@@ -2349,6 +2349,11 @@
|
|
|
2349
2349
|
"code": 1074,
|
|
2350
2350
|
"name": "OracleHasActiveMarkets",
|
|
2351
2351
|
"msg": "Oracle is still linked to active markets"
|
|
2352
|
+
},
|
|
2353
|
+
{
|
|
2354
|
+
"code": 1075,
|
|
2355
|
+
"name": "DuplicateAccount",
|
|
2356
|
+
"msg": "Duplicate account passed to instruction"
|
|
2352
2357
|
}
|
|
2353
2358
|
]
|
|
2354
2359
|
}
|
package/dist/idl/hash.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const ACTA_IDL_SHA256 = "
|
|
1
|
+
export declare const ACTA_IDL_SHA256 = "a86d779d49761e2979103c9ebd3eeb10f85fc9c4fc5848d78d11326e3eedab83";
|
package/dist/idl/hash.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ACTA_IDL_SHA256 = "
|
|
1
|
+
export const ACTA_IDL_SHA256 = "a86d779d49761e2979103c9ebd3eeb10f85fc9c4fc5848d78d11326e3eedab83";
|
package/dist/ws/client.d.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -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":
|
package/dist/ws/types.d.ts
CHANGED
|
@@ -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[];
|