ault-sdk-ts 0.0.2-alpha.26 → 0.0.2-alpha.27
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 +23 -0
- package/dist/core/clob-msgs.d.ts +5 -2
- package/dist/core/clob-responses.d.ts +2 -2
- package/dist/core/cloid.d.ts +4 -0
- package/dist/eip712/msg.generated.d.ts +2 -2
- package/dist/high-level/cloid-lookup.d.ts +9 -0
- package/dist/high-level/types.d.ts +41 -3
- package/dist/high-level-client.d.ts +1 -1
- package/dist/index.cjs +434 -225
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +427 -220
- package/dist/index.js.map +1 -1
- package/dist/proto/gen/ault/clob/v1/genesis.d.ts +8 -0
- package/dist/proto/gen/ault/clob/v1/query.d.ts +6 -0
- package/dist/proto/gen/ault/clob/v1/tx.d.ts +5 -0
- package/dist/rest/clob.d.ts +7 -0
- package/dist/rest/dex-types.generated.d.ts +10 -4
- package/dist/rest/dex.generated.d.ts +39 -11
- package/dist/utils/opaque-id.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -782,6 +782,29 @@ await client.placeMarketOrder({
|
|
|
782
782
|
// succeeded and which failed.
|
|
783
783
|
await client.cancelOrders({ orderIds: [base64ToBytes("base64OrderId...")] });
|
|
784
784
|
|
|
785
|
+
// Client order id (cloid): attach an 8-byte id to an order so you can address
|
|
786
|
+
// it without the chain-assigned order id. It is echoed back (as hex) on the
|
|
787
|
+
// wait-mode result, and cancelOrders accepts a cloid or an order id
|
|
788
|
+
// interchangeably.
|
|
789
|
+
const cloid = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
790
|
+
const withCloid = await client.placeLimitOrder({
|
|
791
|
+
marketId,
|
|
792
|
+
isBuy: true,
|
|
793
|
+
price: "1.5",
|
|
794
|
+
quantity: "100",
|
|
795
|
+
deadline: new Date(Date.now() + 3600_000),
|
|
796
|
+
cloid,
|
|
797
|
+
wait: true,
|
|
798
|
+
});
|
|
799
|
+
console.log(withCloid.cloid); // "0102030405060708"
|
|
800
|
+
|
|
801
|
+
await client.cancelOrders({ orderIds: [cloid] });
|
|
802
|
+
|
|
803
|
+
// Look up an order by (orderer, cloid), chain-first with a dex-api fallback.
|
|
804
|
+
// Live orders resolve from the chain; filled/cancelled ones from the indexer.
|
|
805
|
+
const found = await client.findOrderByCloid(client.address, cloid);
|
|
806
|
+
if (found.source !== "none") console.log(found.source, found.order);
|
|
807
|
+
|
|
785
808
|
// Create a market
|
|
786
809
|
await client.createMarket({
|
|
787
810
|
marketType: MarketType.MARKET_TYPE_SPOT,
|
package/dist/core/clob-msgs.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export declare function buildLimitOrderMsg(sender: string, params: {
|
|
|
7
7
|
postOnly?: boolean;
|
|
8
8
|
builderAddress?: string;
|
|
9
9
|
builderFeeRate?: string;
|
|
10
|
-
|
|
10
|
+
cloid?: Uint8Array;
|
|
11
|
+
}): import("../index.js").Eip712Msg<Omit<import("../proto/gen/ault/clob/v1/tx").MsgPlaceLimitOrder, "builderFeeRate" | "cloid" | "postOnly" | "builderAddress"> & Partial<Pick<import("../proto/gen/ault/clob/v1/tx").MsgPlaceLimitOrder, "builderFeeRate" | "cloid" | "postOnly" | "builderAddress">>, "/ault.clob.v1.MsgPlaceLimitOrder">;
|
|
11
12
|
export declare function buildMarketOrderMsg(sender: string, params: {
|
|
12
13
|
marketId: Uint8Array;
|
|
13
14
|
isBuy: boolean;
|
|
@@ -16,7 +17,9 @@ export declare function buildMarketOrderMsg(sender: string, params: {
|
|
|
16
17
|
priceTolerance?: string;
|
|
17
18
|
builderAddress?: string;
|
|
18
19
|
builderFeeRate?: string;
|
|
19
|
-
|
|
20
|
+
cloid?: Uint8Array;
|
|
21
|
+
}): import("../index.js").Eip712Msg<Omit<import("../proto/gen/ault/clob/v1/tx").MsgPlaceMarketOrder, "builderFeeRate" | "cloid" | "builderAddress" | "worstPrice" | "priceTolerance"> & Partial<Pick<import("../proto/gen/ault/clob/v1/tx").MsgPlaceMarketOrder, "builderFeeRate" | "cloid" | "builderAddress" | "worstPrice" | "priceTolerance">>, "/ault.clob.v1.MsgPlaceMarketOrder">;
|
|
22
|
+
/** Each `orderIds` entry may be an 8-byte cloid or a 16-byte chain order_id. */
|
|
20
23
|
export declare function buildCancelOrdersMsg(sender: string, orderIds: Uint8Array[]): import("../index.js").Eip712Msg<import("../proto/gen/ault/clob/v1/tx").MsgCancelOrders, "/ault.clob.v1.MsgCancelOrders">;
|
|
21
24
|
export declare function buildScaleOrderMsg(sender: string, params: {
|
|
22
25
|
marketId: Uint8Array;
|
|
@@ -12,8 +12,8 @@ type MsgResponse = {
|
|
|
12
12
|
* (which genuinely differ per op) via the `run` thunk.
|
|
13
13
|
*/
|
|
14
14
|
export declare function withWaitDecode<R extends TxResult>(wait: boolean | undefined, run: (wait: boolean) => Promise<TxResult>, decode: (msgResponses: MsgResponse[] | undefined, base: TxResult) => R): Promise<TxResult | R>;
|
|
15
|
-
export declare
|
|
16
|
-
export declare
|
|
15
|
+
export declare const decodeLimitOrderResult: (msgResponses: MsgResponse[] | undefined, base: TxResult) => PlaceOrderResult;
|
|
16
|
+
export declare const decodeMarketOrderResult: (msgResponses: MsgResponse[] | undefined, base: TxResult) => PlaceOrderResult;
|
|
17
17
|
export declare function decodeScaleOrderResult(msgResponses: MsgResponse[] | undefined, base: TxResult): PlaceScaleOrderResult;
|
|
18
18
|
export declare function decodeCancelOrdersResult(msgResponses: MsgResponse[] | undefined, base: TxResult): CancelOrdersResult;
|
|
19
19
|
export {};
|
|
@@ -23,8 +23,8 @@ type MsgCreateMarketInput = Omit<MsgCreateMarket, "makerFeeRate" | "takerFeeRate
|
|
|
23
23
|
type MsgModifyOrdersInput = Omit<MsgModifyOrders, "orders"> & {
|
|
24
24
|
orders: ModifyOrderInput[];
|
|
25
25
|
};
|
|
26
|
-
type MsgPlaceLimitOrderInput = Omit<MsgPlaceLimitOrder, "builderAddress" | "builderFeeRate" | "postOnly"> & Partial<Pick<MsgPlaceLimitOrder, "builderAddress" | "builderFeeRate" | "postOnly">>;
|
|
27
|
-
type MsgPlaceMarketOrderInput = Omit<MsgPlaceMarketOrder, "builderAddress" | "builderFeeRate" | "priceTolerance" | "worstPrice"> & Partial<Pick<MsgPlaceMarketOrder, "builderAddress" | "builderFeeRate" | "priceTolerance" | "worstPrice">>;
|
|
26
|
+
type MsgPlaceLimitOrderInput = Omit<MsgPlaceLimitOrder, "builderAddress" | "builderFeeRate" | "cloid" | "postOnly"> & Partial<Pick<MsgPlaceLimitOrder, "builderAddress" | "builderFeeRate" | "cloid" | "postOnly">>;
|
|
27
|
+
type MsgPlaceMarketOrderInput = Omit<MsgPlaceMarketOrder, "builderAddress" | "builderFeeRate" | "cloid" | "priceTolerance" | "worstPrice"> & Partial<Pick<MsgPlaceMarketOrder, "builderAddress" | "builderFeeRate" | "cloid" | "priceTolerance" | "worstPrice">>;
|
|
28
28
|
type MsgPlaceScaleOrderInput = Omit<MsgPlaceScaleOrder, "builderAddress" | "builderFeeRate" | "postOnly"> & Partial<Pick<MsgPlaceScaleOrder, "builderAddress" | "builderFeeRate" | "postOnly">>;
|
|
29
29
|
type MsgRegisterOperatorInput = Omit<MsgRegisterOperator, "commissionRecipient"> & Partial<Pick<MsgRegisterOperator, "commissionRecipient">>;
|
|
30
30
|
type MsgRegisterTokenPairInput = Omit<MsgRegisterTokenPair, "transferLimit"> & Partial<Pick<MsgRegisterTokenPair, "transferLimit">>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AultClient } from "../client";
|
|
2
|
+
import type { CloidLookupApi } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Chain-first, dex-api-fallback cloid lookup. The chain only indexes a cloid
|
|
5
|
+
* while its order is live, so a clean miss there means filled/cancelled/expired,
|
|
6
|
+
* which the dex-api's historical index answers instead. The two legs return
|
|
7
|
+
* different shapes; see {@link CloidOrder}.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createCloidLookupApi(lowLevel: AultClient): CloidLookupApi;
|
|
@@ -15,6 +15,8 @@ import type { RateLimitApi } from "../rest/ratelimit";
|
|
|
15
15
|
import type { RewardApi } from "../rest/reward";
|
|
16
16
|
import type { StakingApi } from "../rest/staking";
|
|
17
17
|
import type { TokenRegistryApi } from "../rest/tokenregistry";
|
|
18
|
+
import type { OrderResponse as ChainOrderResponse } from "../proto/gen/ault/clob/v1/query";
|
|
19
|
+
import type { OrderResponse as DexOrderResponse } from "../rest/dex.generated";
|
|
18
20
|
import type { License } from "../proto/gen/ault/license/v1/license";
|
|
19
21
|
import type { Params as AgentParams } from "../proto/gen/ault/agent/v1/params";
|
|
20
22
|
import type { Role } from "../proto/gen/ault/authority/v1/authority";
|
|
@@ -152,9 +154,10 @@ export interface OrderWaitOption {
|
|
|
152
154
|
/** Wait for DeliverTx (poll for inclusion) and return the rich result. Default `false`. */
|
|
153
155
|
wait?: boolean;
|
|
154
156
|
}
|
|
155
|
-
/** Limit/market order result when `wait: true`. */
|
|
157
|
+
/** Limit/market order result when `wait: true`. `cloid` is hex, set only when the order carried one. */
|
|
156
158
|
export type PlaceOrderResult = TxResult & {
|
|
157
159
|
orderId: string;
|
|
160
|
+
cloid?: string;
|
|
158
161
|
escrowedAmount?: Coin;
|
|
159
162
|
};
|
|
160
163
|
/** Scale order result when `wait: true`. */
|
|
@@ -166,7 +169,7 @@ export type PlaceScaleOrderResult = TxResult & {
|
|
|
166
169
|
}>;
|
|
167
170
|
escrowedAmount?: Coin;
|
|
168
171
|
};
|
|
169
|
-
/** Cancel result when `wait: true`. `succeeded`/`failed` are
|
|
172
|
+
/** Cancel result when `wait: true`. `succeeded`/`failed` are hex ids (8-byte cloid or 16-byte order id). */
|
|
170
173
|
export type CancelOrdersResult = TxResult & {
|
|
171
174
|
succeeded: string[];
|
|
172
175
|
failed: string[];
|
|
@@ -346,6 +349,8 @@ export type LimitOrderParams = {
|
|
|
346
349
|
postOnly?: boolean;
|
|
347
350
|
builderAddress?: string;
|
|
348
351
|
builderFeeRate?: string;
|
|
352
|
+
/** Optional 8-byte client order id. Omitted from the signed payload when absent. */
|
|
353
|
+
cloid?: Uint8Array;
|
|
349
354
|
};
|
|
350
355
|
export type MarketOrderParams = {
|
|
351
356
|
marketId: Uint8Array;
|
|
@@ -355,6 +360,8 @@ export type MarketOrderParams = {
|
|
|
355
360
|
priceTolerance?: string;
|
|
356
361
|
builderAddress?: string;
|
|
357
362
|
builderFeeRate?: string;
|
|
363
|
+
/** Optional 8-byte client order id. Omitted from the signed payload when absent. */
|
|
364
|
+
cloid?: Uint8Array;
|
|
358
365
|
};
|
|
359
366
|
export type ScaleOrderParams = {
|
|
360
367
|
marketId: Uint8Array;
|
|
@@ -368,6 +375,7 @@ export type ScaleOrderParams = {
|
|
|
368
375
|
builderAddress?: string;
|
|
369
376
|
builderFeeRate?: string;
|
|
370
377
|
};
|
|
378
|
+
/** Each entry may be an 8-byte cloid or a 16-byte chain order_id; the chain accepts both. */
|
|
371
379
|
export type CancelOrdersParams = {
|
|
372
380
|
orderIds: Uint8Array[];
|
|
373
381
|
};
|
|
@@ -515,6 +523,36 @@ export interface ParallelQueryApi {
|
|
|
515
523
|
getLicenseDelegationsParallel(licenseIds: string[]): Promise<LicenseDelegationStatus[]>;
|
|
516
524
|
analyzeLicenses(owner: string): Promise<LicenseAnalysis>;
|
|
517
525
|
}
|
|
526
|
+
/**
|
|
527
|
+
* Result of a chain-first cloid lookup ({@link CloidLookupApi.findOrderByCloid}).
|
|
528
|
+
* The two read surfaces return different shapes, so the source is tagged:
|
|
529
|
+
*
|
|
530
|
+
* - `source: "chain"` — live order from the node's CLOB state; `order` is the chain
|
|
531
|
+
* proto {@link ChainOrderResponse}.
|
|
532
|
+
* - `source: "dex"` — chain had no live match, answered by the indexed dex-api;
|
|
533
|
+
* `order` is the dex REST {@link DexOrderResponse} DTO (`clientOrderId` is hex).
|
|
534
|
+
* - `source: "none"` — neither leg found an order for this cloid.
|
|
535
|
+
*/
|
|
536
|
+
export type CloidOrder = {
|
|
537
|
+
source: "chain";
|
|
538
|
+
order: ChainOrderResponse;
|
|
539
|
+
} | {
|
|
540
|
+
source: "dex";
|
|
541
|
+
order: DexOrderResponse;
|
|
542
|
+
} | {
|
|
543
|
+
source: "none";
|
|
544
|
+
order: null;
|
|
545
|
+
};
|
|
546
|
+
export interface CloidLookupApi {
|
|
547
|
+
/**
|
|
548
|
+
* Look up an order by its `(orderer, cloid)` pair, chain-first with a dex-api
|
|
549
|
+
* fallback. See {@link CloidOrder} for the tagged, source-dependent result shape.
|
|
550
|
+
*
|
|
551
|
+
* @param orderer Account address (bech32 or 0x-hex).
|
|
552
|
+
* @param cloid 8-byte client order id as raw bytes, or its bare-hex string form.
|
|
553
|
+
*/
|
|
554
|
+
findOrderByCloid(orderer: string, cloid: Uint8Array | string): Promise<CloidOrder>;
|
|
555
|
+
}
|
|
518
556
|
export interface AgentTxOptions extends TxOptions {
|
|
519
557
|
timeoutSeconds?: number;
|
|
520
558
|
}
|
|
@@ -580,7 +618,7 @@ export interface AttachAgentOptions {
|
|
|
580
618
|
* High-level client interface for the Ault SDK.
|
|
581
619
|
* Provides simplified methods for common operations.
|
|
582
620
|
*/
|
|
583
|
-
export interface Client extends AccountxTxApi, AgentTxApi, AuthorityTxApi, ClobTxApi, LicenseTxApi, MarketTxApi, MinerTxApi, RateLimitTxApi, RewardTxApi, StakingTxApi, TokenRegistryTxApi, ParallelQueryApi {
|
|
621
|
+
export interface Client extends AccountxTxApi, AgentTxApi, AuthorityTxApi, ClobTxApi, LicenseTxApi, MarketTxApi, MinerTxApi, RateLimitTxApi, RewardTxApi, StakingTxApi, TokenRegistryTxApi, ParallelQueryApi, CloidLookupApi {
|
|
584
622
|
/** Network configuration */
|
|
585
623
|
readonly network: NetworkConfig;
|
|
586
624
|
/** Signer address in Ault bech32 format */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { AgentClobTxApi, AgentSurface, AgentTxOptions, AttachAgentOptions, Client, ClientOptions, FlexibleSignerInput, TxResult, TxOptions, OrderWaitOption, PlaceOrderResult, PlaceScaleOrderResult, CancelOrdersResult, } from "./high-level/types";
|
|
1
|
+
export type { AgentClobTxApi, AgentSurface, AgentTxOptions, AttachAgentOptions, Client, ClientOptions, FlexibleSignerInput, TxResult, TxOptions, OrderWaitOption, PlaceOrderResult, PlaceScaleOrderResult, CancelOrdersResult, CloidOrder, CloidLookupApi, } from "./high-level/types";
|
|
2
2
|
export { createClient } from "./high-level/create-client";
|