ault-sdk-ts 0.15.0 → 0.16.1
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 +59 -23
- package/dist/index.cjs +71 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +67 -39
- package/dist/index.js.map +1 -1
- package/dist/perp/index.d.ts +1 -0
- package/dist/perp/orders.d.ts +6 -3
- package/dist/perp/tick.d.ts +11 -0
- package/dist/rest/clob.d.ts +3 -1
- package/dist/rest/margin.d.ts +2 -2
- package/dist/rest/market-id.d.ts +13 -0
- package/dist/rest/market.d.ts +3 -1
- package/dist/rest/perpetual.d.ts +5 -2
- package/dist/rest/reward.d.ts +3 -1
- package/package.json +1 -1
package/dist/perp/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { type MarginTier, parseMarginTiers, validateMarginTiers, maintenanceMarg
|
|
|
3
3
|
export { SECONDS_PER_FUNDING_WINDOW, fundingRate, averagePremium } from "./funding";
|
|
4
4
|
export { notional, positionValue, unrealizedPnl, pendingFunding, equity, entryPrice, } from "./position";
|
|
5
5
|
export { type IocLimitPriceInput, type IocLimitPrice, iocLimitPrice } from "./orders";
|
|
6
|
+
export { tickSizeAt, isTickPrice, floorTickPrice, ceilTickPrice } from "./tick";
|
package/dist/perp/orders.d.ts
CHANGED
|
@@ -8,8 +8,11 @@ export interface IocLimitPriceInput {
|
|
|
8
8
|
fallbackPrice?: string | null;
|
|
9
9
|
/** Fractional slippage allowance, e.g. "0.005" for 0.5%. */
|
|
10
10
|
slippage: string;
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The market's `tick_precision`: significant digits past the first, not
|
|
13
|
+
* decimal places (see `tickSizeAt`).
|
|
14
|
+
*/
|
|
15
|
+
tickPrecision: number;
|
|
13
16
|
}
|
|
14
17
|
export interface IocLimitPrice {
|
|
15
18
|
/** The limit price to submit with `timeInForce: "ioc"`. */
|
|
@@ -21,7 +24,7 @@ export interface IocLimitPrice {
|
|
|
21
24
|
* Perpetual markets accept limit orders only, so a "market order" is an
|
|
22
25
|
* immediate-or-cancel limit priced through the book: best opposite price
|
|
23
26
|
* plus (buy) or minus (sell) the slippage allowance, rounded away from the
|
|
24
|
-
* reference to the market's price
|
|
27
|
+
* reference to the market's price grid so the order stays marketable. The
|
|
25
28
|
* chain projects margin at this limit price, which bounds the worst fill.
|
|
26
29
|
*/
|
|
27
30
|
export declare function iocLimitPrice(input: IocLimitPriceInput): IocLimitPrice;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The distance between `price` and the next price on the grid above it. */
|
|
2
|
+
export declare function tickSizeAt(price: string, tickPrecision: number): string;
|
|
3
|
+
/** Whether the chain accepts `price` as an order price (`TickAtPrice`). */
|
|
4
|
+
export declare function isTickPrice(price: string, tickPrecision: number): boolean;
|
|
5
|
+
/** The highest price on the grid at or below `price` (`FloorTickAtPrice`). */
|
|
6
|
+
export declare function floorTickPrice(price: string, tickPrecision: number): string;
|
|
7
|
+
/**
|
|
8
|
+
* The lowest price on the grid at or above `price` (`CeilTickAtPrice`). It may
|
|
9
|
+
* carry into the next power of ten: 99,999.995 at precision 6 becomes 100,000.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ceilTickPrice(price: string, tickPrecision: number): string;
|
package/dist/rest/clob.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type RestContext } from "./context";
|
|
2
2
|
import type { PaginationParams } from "./types";
|
|
3
|
+
import { type MarketId } from "../utils/opaque-id";
|
|
3
4
|
import { QueryOrderResponse, QueryOrdersResponse, QueryParamsResponse, QueryTwapOrdersResponse } from "../proto/gen/ault/clob/v1/query";
|
|
4
5
|
import { ConditionalOrder as ConditionalOrderProto } from "../proto/gen/ault/clob/v1/conditional";
|
|
5
6
|
import { MsgPlaceLimitOrder, MsgPlaceMarketOrder } from "../proto/gen/ault/clob/v1/tx";
|
|
@@ -36,7 +37,8 @@ export interface ClobApi {
|
|
|
36
37
|
*/
|
|
37
38
|
getOrderByCloid: (orderer: string, cloid: Uint8Array) => Promise<OrderResponse>;
|
|
38
39
|
getOrders: (params?: {
|
|
39
|
-
|
|
40
|
+
/** Bytes, a `MarketId`, or a hex (optionally 0x-prefixed) or base64 string. */
|
|
41
|
+
marketId?: Uint8Array | MarketId | string;
|
|
40
42
|
pagination?: PaginationParams;
|
|
41
43
|
}) => Promise<QueryOrdersResponse>;
|
|
42
44
|
/**
|
package/dist/rest/margin.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type RestContext } from "./context";
|
|
2
|
-
import { MarketId } from "../utils/opaque-id";
|
|
2
|
+
import type { MarketId } from "../utils/opaque-id";
|
|
3
3
|
import type { PaginationParams } from "./types";
|
|
4
4
|
import { QueryEnabledMarketsResponse, QueryMarginAccountResponse, QueryMarginOrdersResponse, QueryParamsResponse } from "../proto/gen/ault/margin/v1/query";
|
|
5
|
-
/** A market id as raw bytes, a `MarketId`, or a
|
|
5
|
+
/** A market id as raw bytes, a `MarketId`, or a hex (optionally 0x-prefixed) or base64 string. */
|
|
6
6
|
export type MarginQueryMarketId = Uint8Array | MarketId | string;
|
|
7
7
|
/**
|
|
8
8
|
* Chain-side `x/margin` queries. The margin Lending pool id is not a query
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MarketId } from "../utils/opaque-id";
|
|
2
|
+
/**
|
|
3
|
+
* Encodes a market id for a chain REST (grpc-gateway) request, which takes
|
|
4
|
+
* `bytes` params as base64. A string matching the hex pattern is decoded as
|
|
5
|
+
* hex, the form the dex-api returns; any other string is passed through as
|
|
6
|
+
* base64. No real market id has a base64 form that matches the pattern: the
|
|
7
|
+
* id starts with a 0x01/0x02 type byte and an ASCII denom, which puts a
|
|
8
|
+
* character from Q-X or g-n second, and `0x` never occurs in base64.
|
|
9
|
+
*
|
|
10
|
+
* Market ids only. Order ids keep their own rule in `clob.ts`, since the
|
|
11
|
+
* base64 of an order id can be all hex characters.
|
|
12
|
+
*/
|
|
13
|
+
export declare function marketIdToBase64(marketId: Uint8Array | MarketId | string): string;
|
package/dist/rest/market.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { type RestContext } from "./context";
|
|
2
2
|
import type { PaginationParams } from "./types";
|
|
3
|
+
import type { MarketId } from "../utils/opaque-id";
|
|
3
4
|
import { QueryMarketResponse, QueryMarketsResponse, QueryParamsResponse } from "../proto/gen/ault/market/v1/query";
|
|
4
5
|
export interface MarketApi {
|
|
5
6
|
getParams: () => Promise<QueryParamsResponse>;
|
|
6
7
|
getMarkets: (params?: {
|
|
7
8
|
pagination?: PaginationParams;
|
|
8
9
|
}) => Promise<QueryMarketsResponse>;
|
|
9
|
-
|
|
10
|
+
/** `marketId` is bytes, a `MarketId`, or a hex (optionally 0x-prefixed) or base64 string. */
|
|
11
|
+
getMarket: (marketId: Uint8Array | MarketId | string) => Promise<QueryMarketResponse>;
|
|
10
12
|
}
|
|
11
13
|
export declare function createMarketApi(context: RestContext): MarketApi;
|
package/dist/rest/perpetual.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type RestContext } from "./context";
|
|
2
|
-
import { MarketId } from "../utils/opaque-id";
|
|
2
|
+
import type { MarketId } from "../utils/opaque-id";
|
|
3
3
|
import { QueryAccountResponse, QueryAccountRiskResponse, QueryCollateralDenomResponse, QueryFundingResponse, QueryImpactPricesResponse, QueryParamsResponse, QueryPositionResponse, QueryPricesResponse } from "../proto/gen/ault/perpetual/v1/query";
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* A perpetual market id as raw bytes, a `MarketId`, or a hex (optionally
|
|
6
|
+
* 0x-prefixed) or base64 string.
|
|
7
|
+
*/
|
|
5
8
|
export type PerpetualMarketIdInput = Uint8Array | MarketId | string;
|
|
6
9
|
/**
|
|
7
10
|
* Chain-side `x/perpetual` queries.
|
package/dist/rest/reward.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type RestContext } from "./context";
|
|
2
2
|
import type { PaginationParams } from "./types";
|
|
3
|
+
import type { MarketId } from "../utils/opaque-id";
|
|
3
4
|
import { QueryBuilderAllowancesResponse, QueryDeployerShareResponse, QueryEligibleReferrersResponse, QueryParamsResponse, QueryReferralCodeResponse, QueryReferrerResponse } from "../proto/gen/ault/reward/v1/query";
|
|
4
5
|
export type RewardReferrerParams = {
|
|
5
6
|
code: string;
|
|
@@ -15,7 +16,8 @@ export interface RewardApi {
|
|
|
15
16
|
getEligibleReferrers: (params?: {
|
|
16
17
|
pagination?: PaginationParams;
|
|
17
18
|
}) => Promise<QueryEligibleReferrersResponse>;
|
|
18
|
-
|
|
19
|
+
/** `marketId` is bytes, a `MarketId`, or a hex (optionally 0x-prefixed) or base64 string. */
|
|
20
|
+
getDeployerShare: (marketId: Uint8Array | MarketId | string) => Promise<QueryDeployerShareResponse>;
|
|
19
21
|
getBuilderAllowances: (params?: {
|
|
20
22
|
user?: string;
|
|
21
23
|
builder?: string;
|