ault-sdk-ts 0.9.0 → 0.10.0

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 (42) hide show
  1. package/README.md +206 -93
  2. package/dist/agent/attach.d.ts +10 -1
  3. package/dist/agent/sign-and-broadcast.d.ts +1 -1
  4. package/dist/agent/tx/vault.d.ts +11 -0
  5. package/dist/client.d.ts +8 -0
  6. package/dist/core/address.d.ts +6 -0
  7. package/dist/core/clob-msgs.d.ts +9 -0
  8. package/dist/core/lending-gas.d.ts +5 -0
  9. package/dist/core/lending-msgs.d.ts +52 -0
  10. package/dist/core/manifest-types.d.ts +52 -0
  11. package/dist/core/margin-account.d.ts +18 -0
  12. package/dist/core/margin-gas.d.ts +7 -0
  13. package/dist/core/margin-msgs.d.ts +52 -0
  14. package/dist/core/network.d.ts +26 -0
  15. package/dist/core/perpetual-msgs.d.ts +0 -16
  16. package/dist/core/vault-gas.d.ts +8 -0
  17. package/dist/core/vault-msgs.d.ts +150 -0
  18. package/dist/eip712/msg.generated.d.ts +19 -106
  19. package/dist/eip712/registry.d.ts +7 -1
  20. package/dist/high-level/tx/lending.d.ts +3 -0
  21. package/dist/high-level/tx/license.d.ts +1 -1
  22. package/dist/high-level/tx/margin.d.ts +3 -0
  23. package/dist/high-level/tx/vault.d.ts +3 -0
  24. package/dist/high-level/types.d.ts +227 -178
  25. package/dist/index.cjs +16049 -20858
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +6 -0
  28. package/dist/index.js +15992 -20813
  29. package/dist/index.js.map +1 -1
  30. package/dist/rest/dex-types.generated.d.ts +1 -1
  31. package/dist/rest/dex.d.ts +34 -1
  32. package/dist/rest/lending.d.ts +46 -0
  33. package/dist/rest/margin.d.ts +33 -0
  34. package/dist/rest/oracle.d.ts +19 -0
  35. package/dist/rest/pagination.d.ts +6 -2
  36. package/dist/rest/portfolio.d.ts +32 -0
  37. package/dist/rest/vault.d.ts +26 -0
  38. package/package.json +1 -1
  39. package/dist/high-level/tx/authority.d.ts +0 -3
  40. package/dist/high-level/tx/market.d.ts +0 -3
  41. package/dist/high-level/tx/ratelimit.d.ts +0 -3
  42. package/dist/high-level/tx/tokenregistry.d.ts +0 -3
@@ -141,10 +141,10 @@ export declare const GetLendingPoolResponse: zod.ZodObject<{
141
141
  maxOracleDeviationRatio: zod.ZodString;
142
142
  disabledActions: zod.ZodArray<zod.ZodEnum<{
143
143
  supply: "supply";
144
+ borrow: "borrow";
144
145
  withdraw: "withdraw";
145
146
  supplyCollateral: "supplyCollateral";
146
147
  withdrawCollateral: "withdrawCollateral";
147
- borrow: "borrow";
148
148
  repay: "repay";
149
149
  liquidate: "liquidate";
150
150
  }>>;
@@ -1,5 +1,5 @@
1
1
  import type { RestContext } from "./context";
2
- import { getPortfolioHoldings, getPortfolioFlows, getPortfolioPnl, getPortfolioTimeSeries } from "./portfolio";
2
+ import { getPortfolioHoldings, getPortfolioFlows, getPortfolioPnl, getPortfolioTimeSeries, getPortfolioVaults } from "./portfolio";
3
3
  export { initDexContext } from "./dex-fetcher";
4
4
  /**
5
5
  * Creates a DEX API instance bound to the given REST context.
@@ -56,5 +56,38 @@ export declare function createDexApi(context: RestContext): {
56
56
  listPerpLedger: (owner: string, params?: import("./dex.generated").ListPerpLedgerParams, options?: RequestInit) => Promise<import("./dex.generated").listPerpLedgerResponse>;
57
57
  listPerpFundingPayments: (owner: string, params?: import("./dex.generated").ListPerpFundingPaymentsParams, options?: RequestInit) => Promise<import("./dex.generated").listPerpFundingPaymentsResponse>;
58
58
  listPerpCloseouts: (owner: string, params?: import("./dex.generated").ListPerpCloseoutsParams, options?: RequestInit) => Promise<import("./dex.generated").listPerpCloseoutsResponse>;
59
+ listRewardTiers: (params?: import("./dex.generated").ListRewardTiersParams, options?: RequestInit) => Promise<import("./dex.generated").listRewardTiersResponse>;
60
+ getRewardTier: (address: string, options?: RequestInit) => Promise<import("./dex.generated").getRewardTierResponse>;
61
+ getReferralStatus: (address: string, options?: RequestInit) => Promise<import("./dex.generated").getReferralStatusResponse>;
62
+ getSDKManifest: (options?: RequestInit) => Promise<import("./dex.generated").getSDKManifestResponse>;
63
+ getLendingParams: (options?: RequestInit) => Promise<import("./dex.generated").getLendingParamsResponse>;
64
+ listLendingPools: (params?: import("./dex.generated").ListLendingPoolsParams, options?: RequestInit) => Promise<import("./dex.generated").listLendingPoolsResponse>;
65
+ getLendingPool: (poolId: number, options?: RequestInit) => Promise<import("./dex.generated").getLendingPoolResponse>;
66
+ listLendingAssets: (poolId: number, params?: import("./dex.generated").ListLendingAssetsParams, options?: RequestInit) => Promise<import("./dex.generated").listLendingAssetsResponse>;
67
+ getLendingAsset: (poolId: number, denom: string, options?: RequestInit) => Promise<import("./dex.generated").getLendingAssetResponse>;
68
+ getLendingAssetState: (poolId: number, denom: string, options?: RequestInit) => Promise<import("./dex.generated").getLendingAssetStateResponse>;
69
+ getLendingAssetOracle: (poolId: number, denom: string, options?: RequestInit) => Promise<import("./dex.generated").getLendingAssetOracleResponse>;
70
+ getLendingAssetStateHistory: (poolId: number, denom: string, params: import("./dex.generated").GetLendingAssetStateHistoryParams, options?: RequestInit) => Promise<import("./dex.generated").getLendingAssetStateHistoryResponse>;
71
+ getLendingAPYAverages: (poolId: number, denom: string, params?: import("./dex.generated").GetLendingAPYAveragesParams, options?: RequestInit) => Promise<import("./dex.generated").getLendingAPYAveragesResponse>;
72
+ listLendingAccountPositions: (address: string, params?: import("./dex.generated").ListLendingAccountPositionsParams, options?: RequestInit) => Promise<import("./dex.generated").listLendingAccountPositionsResponse>;
73
+ getLendingPosition: (poolId: number, address: string, options?: RequestInit) => Promise<import("./dex.generated").getLendingPositionResponse>;
74
+ getLendingPositionHistory: (poolId: number, address: string, params: import("./dex.generated").GetLendingPositionHistoryParams, options?: RequestInit) => Promise<import("./dex.generated").getLendingPositionHistoryResponse>;
75
+ listLendingLiquidations: (params?: import("./dex.generated").ListLendingLiquidationsParams, options?: RequestInit) => Promise<import("./dex.generated").listLendingLiquidationsResponse>;
76
+ listLendingDeficits: (params?: import("./dex.generated").ListLendingDeficitsParams, options?: RequestInit) => Promise<import("./dex.generated").listLendingDeficitsResponse>;
77
+ getLendingInsuranceFund: (params: import("./dex.generated").GetLendingInsuranceFundParams, options?: RequestInit) => Promise<import("./dex.generated").getLendingInsuranceFundResponse>;
78
+ getLendingProtocolRevenue: (params: import("./dex.generated").GetLendingProtocolRevenueParams, options?: RequestInit) => Promise<import("./dex.generated").getLendingProtocolRevenueResponse>;
79
+ getMarginParams: (options?: RequestInit) => Promise<import("./dex.generated").getMarginParamsResponse>;
80
+ listMarginMarkets: (params?: import("./dex.generated").ListMarginMarketsParams, options?: RequestInit) => Promise<import("./dex.generated").listMarginMarketsResponse>;
81
+ listMarginAccounts: (owner: string, params?: import("./dex.generated").ListMarginAccountsParams, options?: RequestInit) => Promise<import("./dex.generated").listMarginAccountsResponse>;
82
+ listMarginAccountPositions: (owner: string, params?: import("./dex.generated").ListMarginAccountPositionsParams, options?: RequestInit) => Promise<import("./dex.generated").listMarginAccountPositionsResponse>;
83
+ getMarginPosition: (address: string, options?: RequestInit) => Promise<import("./dex.generated").getMarginPositionResponse>;
84
+ listMarginActivity: (params?: import("./dex.generated").ListMarginActivityParams, options?: RequestInit) => Promise<import("./dex.generated").listMarginActivityResponse>;
85
+ listMarginLiquidations: (params?: import("./dex.generated").ListMarginLiquidationsParams, options?: RequestInit) => Promise<import("./dex.generated").listMarginLiquidationsResponse>;
86
+ listVaults: (params?: import("./dex.generated").ListVaultsParams, options?: RequestInit) => Promise<import("./dex.generated").listVaultsResponse>;
87
+ getVault: (vaultAddress: string, params?: import("./dex.generated").GetVaultParams, options?: RequestInit) => Promise<import("./dex.generated").getVaultResponse>;
88
+ listVaultActivity: (vaultAddress: string, params?: import("./dex.generated").ListVaultActivityParams, options?: RequestInit) => Promise<import("./dex.generated").listVaultActivityResponse>;
89
+ listVaultRedemptions: (vaultAddress: string, params?: import("./dex.generated").ListVaultRedemptionsParams, options?: RequestInit) => Promise<import("./dex.generated").listVaultRedemptionsResponse>;
90
+ getPortfolioVaults: typeof getPortfolioVaults;
91
+ listOraclePrices: (options?: RequestInit) => Promise<import("./dex.generated").listOraclePricesResponse>;
59
92
  };
60
93
  export type DexApi = ReturnType<typeof createDexApi>;
@@ -0,0 +1,46 @@
1
+ import { type RestContext } from "./context";
2
+ import type { PaginationParams } from "./types";
3
+ import { QueryAssetResponse, QueryAssetsResponse, QueryBorrowRateResponse, QueryDeficitResponse, QueryDeficitsResponse, QueryHealthResponse, QueryInsuranceFundBalanceResponse, QueryParamsResponse, QueryPendingAssetUpdatesResponse, QueryPoolResponse, QueryPoolsResponse, QueryProtocolRevenueBalanceResponse, QuerySharesResponse, QuerySupplyRateResponse } from "../proto/gen/ault/lending/v1/query";
4
+ type PoolId = bigint | number | string;
5
+ /**
6
+ * Chain-side `x/lending` queries, read at the node's latest height. The
7
+ * dex-api lending routes serve the same data indexed, with history and APYs;
8
+ * reach for these when a read must reflect the chain right now (a health
9
+ * check before a withdrawal) or for what the indexer does not keep, such as
10
+ * pending asset updates. Amounts are base-unit integers, shares LegacyDec.
11
+ */
12
+ export interface LendingApi {
13
+ getParams: () => Promise<QueryParamsResponse>;
14
+ getPools: (params?: {
15
+ pagination?: PaginationParams;
16
+ }) => Promise<QueryPoolsResponse>;
17
+ getPool: (poolId: PoolId) => Promise<QueryPoolResponse>;
18
+ getAssets: (poolId: PoolId, params?: {
19
+ pagination?: PaginationParams;
20
+ }) => Promise<QueryAssetsResponse>;
21
+ getAsset: (poolId: PoolId, denom: string) => Promise<QueryAssetResponse>;
22
+ /** Supply, collateral and borrow shares of `owner` in one denom of a pool. */
23
+ getShares: (poolId: PoolId, owner: string, denom: string) => Promise<QuerySharesResponse>;
24
+ /**
25
+ * Health of `owner`'s position in a pool. The chain fails the whole read
26
+ * when any oracle price it needs is stale, so expect errors, not zeros.
27
+ */
28
+ getHealth: (poolId: PoolId, owner: string) => Promise<QueryHealthResponse>;
29
+ getBorrowRate: (poolId: PoolId, denom: string) => Promise<QueryBorrowRateResponse>;
30
+ getSupplyRate: (poolId: PoolId, denom: string) => Promise<QuerySupplyRateResponse>;
31
+ getInsuranceFundBalance: (denom: string) => Promise<QueryInsuranceFundBalanceResponse>;
32
+ getProtocolRevenueBalance: (denom: string) => Promise<QueryProtocolRevenueBalanceResponse>;
33
+ getDeficit: (poolId: PoolId, denom: string) => Promise<QueryDeficitResponse>;
34
+ getDeficits: (params?: {
35
+ pagination?: PaginationParams;
36
+ }) => Promise<QueryDeficitsResponse>;
37
+ /**
38
+ * Risk updates scheduled for a pool's assets and not yet applied. The
39
+ * dex-api does not index these; this is the only source.
40
+ */
41
+ getPendingAssetUpdates: (poolId: PoolId, params?: {
42
+ pagination?: PaginationParams;
43
+ }) => Promise<QueryPendingAssetUpdatesResponse>;
44
+ }
45
+ export declare function createLendingApi(context: RestContext): LendingApi;
46
+ export {};
@@ -0,0 +1,33 @@
1
+ import { type RestContext } from "./context";
2
+ import { MarketId } from "../utils/opaque-id";
3
+ import type { PaginationParams } from "./types";
4
+ import { QueryEnabledMarketsResponse, QueryMarginAccountResponse, QueryMarginOrdersResponse, QueryParamsResponse, QueryPendingSettlementsResponse } from "../proto/gen/ault/margin/v1/query";
5
+ /** A market id as raw bytes, a `MarketId`, or a base64 string (grpc-gateway form). */
6
+ export type MarginQueryMarketId = Uint8Array | MarketId | string;
7
+ /**
8
+ * Chain-side `x/margin` queries. The margin Lending pool id is not a query
9
+ * here; the dex-api reports it as `marginLendingPoolId` on /margin/params.
10
+ */
11
+ export interface MarginApi {
12
+ getParams: () => Promise<QueryParamsResponse>;
13
+ /** Market ids open to margin orders (base64 in the JSON response). */
14
+ getEnabledMarkets: (params?: {
15
+ pagination?: PaginationParams;
16
+ }) => Promise<QueryEnabledMarketsResponse>;
17
+ /**
18
+ * The owner's margin account for a market, or the cross account without
19
+ * `marketId`: its derived address and the collateral committed to resting
20
+ * orders. Collateral and debt themselves live in x/lending under that
21
+ * address (see `lending.getShares` / `lending.getHealth`).
22
+ */
23
+ getMarginAccount: (owner: string, marketId?: MarginQueryMarketId) => Promise<QueryMarginAccountResponse>;
24
+ /** Funding state of the open orders of a derived margin account (not its owner). */
25
+ getMarginOrders: (account: string, params?: {
26
+ pagination?: PaginationParams;
27
+ }) => Promise<QueryMarginOrdersResponse>;
28
+ /** Fill proceeds waiting to be credited back; empty in normal operation. */
29
+ getPendingSettlements: (params?: {
30
+ pagination?: PaginationParams;
31
+ }) => Promise<QueryPendingSettlementsResponse>;
32
+ }
33
+ export declare function createMarginApi(context: RestContext): MarginApi;
@@ -0,0 +1,19 @@
1
+ import { type RestContext } from "./context";
2
+ import type { PaginationParams } from "./types";
3
+ import { QueryFeedResponse, QueryFeedsResponse, QueryMarketStatusResponse, QueryOracleResponse, QueryParamsResponse } from "../proto/gen/ault/oracle/v1/query";
4
+ /**
5
+ * Chain-side `x/oracle` queries. The dex-api serves the same feeds indexed at
6
+ * /oracle/prices; these read the chain's current state directly.
7
+ */
8
+ export interface OracleApi {
9
+ getParams: () => Promise<QueryParamsResponse>;
10
+ getFeeds: (params?: {
11
+ pagination?: PaginationParams;
12
+ }) => Promise<QueryFeedsResponse>;
13
+ getFeed: (feedId: string) => Promise<QueryFeedResponse>;
14
+ /** The latest price the chain holds for a feed, with its update time. */
15
+ getOracle: (feedId: string) => Promise<QueryOracleResponse>;
16
+ /** Whether the external market behind a feed (e.g. "nasdaq") is open. */
17
+ getMarketStatus: (marketId: string) => Promise<QueryMarketStatusResponse>;
18
+ }
19
+ export declare function createOracleApi(context: RestContext): OracleApi;
@@ -25,12 +25,16 @@ interface PagedResponse {
25
25
  * `(p) => api.listMyTrades({ address, ...p })`. Every page repeats the
26
26
  * caller's filters; only `cursor` changes between requests. A caller-supplied
27
27
  * `params.cursor` resumes a previous walk.
28
+ *
29
+ * Most feeds return a bare row array. The vault and margin feeds wrap theirs
30
+ * in an envelope (`{ vaults: [...] }`, `{ activity: [...] }`); pass `rowsOf`
31
+ * to pick the array out, e.g. `(body) => body.activity`.
28
32
  */
29
33
  export declare function paginate<T>(fetchPage: (params: {
30
34
  cursor?: string;
31
35
  }) => Promise<PagedResponse>, params?: {
32
36
  cursor?: string;
33
- }): AsyncGenerator<CursorPage<T>, void, void>;
37
+ }, rowsOf?: (body: never) => T[]): AsyncGenerator<CursorPage<T>, void, void>;
34
38
  /**
35
39
  * Collects pages into one flat array, stopping at `max` rows. `max` is
36
40
  * required on purpose: an unbounded collect against a busy account is a way
@@ -41,5 +45,5 @@ export declare function collectPages<T>(fetchPage: (params: {
41
45
  cursor?: string;
42
46
  }) => Promise<PagedResponse>, max: number, params?: {
43
47
  cursor?: string;
44
- }): Promise<T[]>;
48
+ }, rowsOf?: (body: never) => T[]): Promise<T[]>;
45
49
  export {};
@@ -1,3 +1,4 @@
1
+ import type { VaultFollowerState } from "./dex.generated";
1
2
  export interface PortfolioHolding {
2
3
  denom: string;
3
4
  symbol: string;
@@ -92,6 +93,31 @@ export interface PortfolioTimeSeries {
92
93
  partial: boolean;
93
94
  asOf: number;
94
95
  }
96
+ /**
97
+ * One vault position of an account: the vault detail's follower fields plus
98
+ * the vault's type, status and denom. `entryValue` is USD for Trading vaults
99
+ * and vault-denom units for Lending vaults, which is why `pnl` and
100
+ * `allTimePnl` are null on Lending vaults.
101
+ */
102
+ export type PortfolioVaultEquity = VaultFollowerState & {
103
+ vaultAddress: string;
104
+ vaultType: "lending" | "trading";
105
+ vaultStatus: "active" | "paused" | "closed";
106
+ vaultDenom: string;
107
+ /** The most advanced unsettled redemption claim; null when none. */
108
+ redemptionStatus: "queued" | "processing" | null;
109
+ };
110
+ export interface PortfolioVaults {
111
+ user: string;
112
+ vaultEquities: PortfolioVaultEquity[];
113
+ asOf: number;
114
+ }
115
+ export interface PortfolioVaultsParams {
116
+ vault_type?: "lending" | "trading";
117
+ status?: "active" | "paused" | "closed";
118
+ limit?: number;
119
+ cursor?: string;
120
+ }
95
121
  export interface RestResponse<T> {
96
122
  data: T;
97
123
  status: number;
@@ -101,3 +127,9 @@ export declare function getPortfolioHoldings(address: string, options?: RequestI
101
127
  export declare function getPortfolioFlows(address: string, range?: PortfolioTimeRange, options?: RequestInit): Promise<RestResponse<PortfolioFlows>>;
102
128
  export declare function getPortfolioPnl(address: string, range?: PortfolioTimeRange, options?: RequestInit): Promise<RestResponse<PortfolioPnL>>;
103
129
  export declare function getPortfolioTimeSeries(address: string, range?: PortfolioTimeRange, options?: RequestInit): Promise<RestResponse<PortfolioTimeSeries>>;
130
+ /**
131
+ * Vaults the account holds available or queued shares in, ascending by vault
132
+ * address. Paged with the `X-Next-Cursor` header; walk it with
133
+ * `paginate((p) => getPortfolioVaults(address, p), {}, (body) => body.vaultEquities)`.
134
+ */
135
+ export declare function getPortfolioVaults(address: string, params?: PortfolioVaultsParams, options?: RequestInit): Promise<RestResponse<PortfolioVaults>>;
@@ -0,0 +1,26 @@
1
+ import { type RestContext } from "./context";
2
+ import type { PaginationParams } from "./types";
3
+ import { QueryOracleFeedResponse, QueryParamsResponse, QueryPositionResponse, QueryRedemptionRequestResponse, QueryRedemptionRequestsResponse, QueryVaultResponse, QueryVaultsResponse, QueryVaultValueResponse } from "../proto/gen/ault/vault/v1/query";
4
+ /**
5
+ * Chain-side `x/vault` queries. Vault addresses are module-derived bech32
6
+ * accounts; the dex-api vault routes add TVL, share price and per-user PnL on
7
+ * top of these.
8
+ */
9
+ export interface VaultApi {
10
+ getParams: () => Promise<QueryParamsResponse>;
11
+ getVaults: (params?: {
12
+ pagination?: PaginationParams;
13
+ }) => Promise<QueryVaultsResponse>;
14
+ getVault: (vaultAddress: string) => Promise<QueryVaultResponse>;
15
+ /** The vault's current value as the chain computes it for deposits and redemptions. */
16
+ getVaultValue: (vaultAddress: string) => Promise<QueryVaultValueResponse>;
17
+ /** A depositor's shares in a vault and the entry value they were minted at. */
18
+ getPosition: (vaultAddress: string, depositor: string) => Promise<QueryPositionResponse>;
19
+ getRedemptionRequest: (vaultAddress: string, requestId: bigint | number | string) => Promise<QueryRedemptionRequestResponse>;
20
+ getRedemptionRequests: (vaultAddress: string, params?: {
21
+ pagination?: PaginationParams;
22
+ }) => Promise<QueryRedemptionRequestsResponse>;
23
+ /** The oracle feed x/vault prices a denom with. */
24
+ getOracleFeed: (denom: string) => Promise<QueryOracleFeedResponse>;
25
+ }
26
+ export declare function createVaultApi(context: RestContext): VaultApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ault-sdk-ts",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "TypeScript SDK for the Ault blockchain with high-level transaction methods and REST query clients",
5
5
  "keywords": [
6
6
  "ault",
@@ -1,3 +0,0 @@
1
- import type { AuthorityTxApi } from "../types";
2
- import type { TxModuleContext } from "./context";
3
- export declare function createAuthorityTxApi({ signerAddress, exec }: TxModuleContext): AuthorityTxApi;
@@ -1,3 +0,0 @@
1
- import type { MarketTxApi } from "../types";
2
- import type { TxModuleContext } from "./context";
3
- export declare function createMarketTxApi({ signerAddress, exec }: TxModuleContext): MarketTxApi;
@@ -1,3 +0,0 @@
1
- import type { RateLimitTxApi } from "../types";
2
- import type { TxModuleContext } from "./context";
3
- export declare function createRateLimitTxApi({ signerAddress, exec }: TxModuleContext): RateLimitTxApi;
@@ -1,3 +0,0 @@
1
- import type { TokenRegistryTxApi } from "../types";
2
- import type { TxModuleContext } from "./context";
3
- export declare function createTokenRegistryTxApi({ signerAddress, exec, }: TxModuleContext): TokenRegistryTxApi;