@acta-markets/ts-sdk 0.0.6-beta → 0.0.8-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/README.md +11 -11
- package/dist/cjs/ws/client.js +9 -4
- package/dist/ws/client.js +9 -4
- package/dist/ws/types.d.ts +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,10 +8,10 @@ Generated by Codama.
|
|
|
8
8
|
|
|
9
9
|
## Package
|
|
10
10
|
|
|
11
|
-
Published package: **`@acta-markets/ts-sdk
|
|
11
|
+
Published package: **`@acta-markets/ts-sdk@0.0.6-beta`** (ESM-first, CJS fallback)
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
yarn add @acta-markets/ts-sdk
|
|
14
|
+
yarn add @acta-markets/ts-sdk@0.0.6-beta
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Tooling
|
|
@@ -38,7 +38,7 @@ All instructions/codecs are in `src/generated/instructions` (Codama @solana/kit
|
|
|
38
38
|
You can instantiate WS-only, chain-only, or both:
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
|
-
import { ActaClient } from "@acta-markets/ts-sdk
|
|
41
|
+
import { ActaClient } from "@acta-markets/ts-sdk";
|
|
42
42
|
|
|
43
43
|
// WS-only
|
|
44
44
|
const c1 = new ActaClient({ ws: { url: "wss://...", role: "taker" } });
|
|
@@ -52,8 +52,8 @@ const c2 = new ActaClient({ chain: { rpc, rpcSubscriptions, payer } });
|
|
|
52
52
|
### 1) Connect to WS anonymously, then authenticate on “Connect wallet”
|
|
53
53
|
|
|
54
54
|
```ts
|
|
55
|
-
import { ActaClient } from "@acta-markets/ts-sdk
|
|
56
|
-
import { WalletAuthProvider } from "@acta-markets/ts-sdk
|
|
55
|
+
import { ActaClient } from "@acta-markets/ts-sdk";
|
|
56
|
+
import { WalletAuthProvider } from "@acta-markets/ts-sdk/ws";
|
|
57
57
|
|
|
58
58
|
const client = new ActaClient({ ws: { url: "wss://localhost:8080", role: "taker" } });
|
|
59
59
|
const auth = new WalletAuthProvider({
|
|
@@ -125,7 +125,7 @@ await client.ws!.acceptQuote(rfqId, makerPubkeyBase58, orderIdHex32);
|
|
|
125
125
|
client.ws!.on("sponsoredTxToSign", async (orderIdHex, txBase64, signatureDeadline) => {
|
|
126
126
|
// If your wallet exposes `signTransaction` (Phantom/Privy via adapters), you can use it.
|
|
127
127
|
// Alternatively (lighter): sign the **message bytes** and fill signature slot 1.
|
|
128
|
-
const signedTxBase64 = await import("@acta-markets/ts-sdk
|
|
128
|
+
const signedTxBase64 = await import("@acta-markets/ts-sdk/ws").then(({ signSponsoredTxBase64 }) =>
|
|
129
129
|
signSponsoredTxBase64({
|
|
130
130
|
txBase64,
|
|
131
131
|
taker: { signMessage: (msg: Uint8Array) => wallet.signMessage(msg) },
|
|
@@ -184,7 +184,7 @@ Then annualize using time to expiry \(dt = expiry\_ts - now\):
|
|
|
184
184
|
TS SDK helper (WS-only, no on-chain RPC needed):
|
|
185
185
|
|
|
186
186
|
```ts
|
|
187
|
-
import { ws } from "@acta-markets/ts-sdk
|
|
187
|
+
import { ws } from "@acta-markets/ts-sdk";
|
|
188
188
|
|
|
189
189
|
const secondsToExpiry = rfq.market.expiry_ts - Math.floor(Date.now() / 1000);
|
|
190
190
|
|
|
@@ -207,7 +207,7 @@ Note:
|
|
|
207
207
|
Build the minimal instruction set for `open_position` (maker ed25519 verify + open ix):
|
|
208
208
|
|
|
209
209
|
```ts
|
|
210
|
-
import { chain } from "@acta-markets/ts-sdk
|
|
210
|
+
import { chain } from "@acta-markets/ts-sdk";
|
|
211
211
|
|
|
212
212
|
const built = await chain.flows.buildOpenPositionFlowIxs({
|
|
213
213
|
underlyingMint,
|
|
@@ -237,7 +237,7 @@ By default the SDK targets the mainnet deployment program id exported from `src/
|
|
|
237
237
|
For tests/devnet you can override it at runtime:
|
|
238
238
|
|
|
239
239
|
```ts
|
|
240
|
-
import { setActaProgramId, clearActaProgramId } from "@acta-markets/ts-sdk
|
|
240
|
+
import { setActaProgramId, clearActaProgramId } from "@acta-markets/ts-sdk";
|
|
241
241
|
// setActaProgramId("...devnet program id..." as Address<string>);
|
|
242
242
|
// clearActaProgramId();
|
|
243
243
|
```
|
|
@@ -249,14 +249,14 @@ On-chain expects an **Ed25519 verify instruction** (maker) immediately followed
|
|
|
249
249
|
```ts
|
|
250
250
|
import { randomBytes } from "crypto";
|
|
251
251
|
import { Address } from "@solana/addresses";
|
|
252
|
-
import { PositionType } from "@acta-markets/ts-sdk
|
|
252
|
+
import { PositionType } from "@acta-markets/ts-sdk";
|
|
253
253
|
import {
|
|
254
254
|
computeOrderId,
|
|
255
255
|
orderSignatureInstruction,
|
|
256
256
|
findMarketPda,
|
|
257
257
|
findPositionPda,
|
|
258
258
|
buildOpenPositionIx,
|
|
259
|
-
} from "@acta-markets/ts-sdk
|
|
259
|
+
} from "@acta-markets/ts-sdk/chain";
|
|
260
260
|
|
|
261
261
|
const nonce = Buffer.from(randomBytes(8)).readBigUInt64LE(0);
|
|
262
262
|
const orderId = computeOrderId({
|
package/dist/cjs/ws/client.js
CHANGED
|
@@ -406,7 +406,7 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
406
406
|
}
|
|
407
407
|
this.setConnectionState("connecting");
|
|
408
408
|
this.emit("connecting");
|
|
409
|
-
const endpoint = this.options.role === "maker" ? "/
|
|
409
|
+
const endpoint = this.options.role === "maker" ? "/maker" : "/taker";
|
|
410
410
|
const url = `${this.options.url}${endpoint}`;
|
|
411
411
|
this.log(`Connecting to ${url}`);
|
|
412
412
|
const ws = this.options.makeSocket(url);
|
|
@@ -573,9 +573,13 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
573
573
|
const rfq = this.state.activeRfqs.get(message.data.rfq_id);
|
|
574
574
|
if (rfq) {
|
|
575
575
|
const nextCount = rfq.quotes_count + 1;
|
|
576
|
+
// Use net_price for best_price tracking to stay consistent with
|
|
577
|
+
// server-side best_price (also net). Fall back to gross price when
|
|
578
|
+
// fee config is unavailable (net_price absent).
|
|
579
|
+
const quotePrice = message.data.net_price ?? message.data.price;
|
|
576
580
|
const nextBest = rfq.best_price === null
|
|
577
|
-
?
|
|
578
|
-
: Math.max(rfq.best_price,
|
|
581
|
+
? quotePrice
|
|
582
|
+
: Math.max(rfq.best_price, quotePrice);
|
|
579
583
|
this.state.activeRfqs.set(message.data.rfq_id, {
|
|
580
584
|
...rfq,
|
|
581
585
|
quotes_count: nextCount,
|
|
@@ -589,7 +593,8 @@ class ActaWsClient extends TypedEventEmitter {
|
|
|
589
593
|
{
|
|
590
594
|
const rfq = this.state.activeRfqs.get(message.data.rfq_id);
|
|
591
595
|
if (rfq) {
|
|
592
|
-
|
|
596
|
+
// Use net_price for consistency with server-side best_price (also net).
|
|
597
|
+
const prices = message.data.quotes.map((q) => q.net_price ?? q.price);
|
|
593
598
|
const nextBest = prices.length === 0 ? null : Math.max(...prices);
|
|
594
599
|
this.state.activeRfqs.set(message.data.rfq_id, {
|
|
595
600
|
...rfq,
|
package/dist/ws/client.js
CHANGED
|
@@ -403,7 +403,7 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
403
403
|
}
|
|
404
404
|
this.setConnectionState("connecting");
|
|
405
405
|
this.emit("connecting");
|
|
406
|
-
const endpoint = this.options.role === "maker" ? "/
|
|
406
|
+
const endpoint = this.options.role === "maker" ? "/maker" : "/taker";
|
|
407
407
|
const url = `${this.options.url}${endpoint}`;
|
|
408
408
|
this.log(`Connecting to ${url}`);
|
|
409
409
|
const ws = this.options.makeSocket(url);
|
|
@@ -570,9 +570,13 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
570
570
|
const rfq = this.state.activeRfqs.get(message.data.rfq_id);
|
|
571
571
|
if (rfq) {
|
|
572
572
|
const nextCount = rfq.quotes_count + 1;
|
|
573
|
+
// Use net_price for best_price tracking to stay consistent with
|
|
574
|
+
// server-side best_price (also net). Fall back to gross price when
|
|
575
|
+
// fee config is unavailable (net_price absent).
|
|
576
|
+
const quotePrice = message.data.net_price ?? message.data.price;
|
|
573
577
|
const nextBest = rfq.best_price === null
|
|
574
|
-
?
|
|
575
|
-
: Math.max(rfq.best_price,
|
|
578
|
+
? quotePrice
|
|
579
|
+
: Math.max(rfq.best_price, quotePrice);
|
|
576
580
|
this.state.activeRfqs.set(message.data.rfq_id, {
|
|
577
581
|
...rfq,
|
|
578
582
|
quotes_count: nextCount,
|
|
@@ -586,7 +590,8 @@ export class ActaWsClient extends TypedEventEmitter {
|
|
|
586
590
|
{
|
|
587
591
|
const rfq = this.state.activeRfqs.get(message.data.rfq_id);
|
|
588
592
|
if (rfq) {
|
|
589
|
-
|
|
593
|
+
// Use net_price for consistency with server-side best_price (also net).
|
|
594
|
+
const prices = message.data.quotes.map((q) => q.net_price ?? q.price);
|
|
590
595
|
const nextBest = prices.length === 0 ? null : Math.max(...prices);
|
|
591
596
|
this.state.activeRfqs.set(message.data.rfq_id, {
|
|
592
597
|
...rfq,
|
package/dist/ws/types.d.ts
CHANGED
|
@@ -790,12 +790,20 @@ export type QuoteReceivedMessage = {
|
|
|
790
790
|
rfq_id: UuidString;
|
|
791
791
|
strike: WsU64;
|
|
792
792
|
maker: Address<string>;
|
|
793
|
+
/** Gross price from maker. Hash-bound via order_id — use for AcceptQuote / order verification. */
|
|
793
794
|
price: WsU64;
|
|
794
795
|
valid_until: WsU64;
|
|
795
796
|
/** u64 nonce used in the orderId preimage. */
|
|
796
797
|
nonce: WsU64;
|
|
797
798
|
/** Order ID hex string (64 chars). */
|
|
798
799
|
order_id: OrderIdHex32;
|
|
800
|
+
/**
|
|
801
|
+
* Net price after protocol fee deduction (display only).
|
|
802
|
+
* `net_price = price * (10_000 - fee_bps) / 10_000`
|
|
803
|
+
* Present when the server has loaded the on-chain fee config.
|
|
804
|
+
* Use this for UI display; use `price` for all order operations.
|
|
805
|
+
*/
|
|
806
|
+
net_price?: WsU64 | null;
|
|
799
807
|
};
|
|
800
808
|
export type QuotesUpdateMessage = {
|
|
801
809
|
rfq_id: UuidString;
|