ault-sdk-ts 0.12.0 → 0.14.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.
- package/README.md +9 -4
- package/dist/core/network.d.ts +2 -2
- package/dist/high-level/types.d.ts +9 -6
- package/dist/index.cjs +194 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +194 -32
- package/dist/index.js.map +1 -1
- package/dist/proto/gen/ault/margin/v1/tx.d.ts +15 -0
- package/dist/proto/gen/ault/oracle/v1/tx.d.ts +4 -4
- package/dist/proto/gen/ault/vault/v1/tx.d.ts +67 -0
- package/dist/proto/gen/ault/vault/v1/vault.d.ts +2 -0
- package/dist/rest/dex-types.generated.d.ts +11 -4
- package/dist/rest/dex.d.ts +1 -2
- package/dist/rest/dex.generated.d.ts +11 -4
- package/dist/rest/portfolio.d.ts +0 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/core/user-agent.ts
|
|
8
|
-
var SDK_VERSION = "0.
|
|
8
|
+
var SDK_VERSION = "0.14.0";
|
|
9
9
|
var USER_AGENT = `ault-sdk-ts/${SDK_VERSION}`;
|
|
10
10
|
function isServerRuntime() {
|
|
11
11
|
if (typeof document !== "undefined") return false;
|
|
@@ -544,13 +544,13 @@ var GAS_CONSTANTS = {
|
|
|
544
544
|
VAULT_CREATE_TRADING_BASE: 19e4,
|
|
545
545
|
VAULT_CREATE_PER_MARKET: 9e3,
|
|
546
546
|
VAULT_CREATE_LENDING_BASE: 124e3,
|
|
547
|
-
VAULT_CREATE_PER_LENDING_POOL:
|
|
547
|
+
VAULT_CREATE_PER_LENDING_POOL: 7e3,
|
|
548
548
|
VAULT_UPDATE_MANAGER: 95e3,
|
|
549
549
|
// A config update is priced like creation: per spot market or per pool.
|
|
550
550
|
VAULT_UPDATE_CONFIG_TRADING_BASE: 85e3,
|
|
551
551
|
VAULT_UPDATE_CONFIG_PER_MARKET: 9e3,
|
|
552
552
|
VAULT_UPDATE_CONFIG_LENDING_BASE: 1e5,
|
|
553
|
-
VAULT_UPDATE_CONFIG_PER_POOL:
|
|
553
|
+
VAULT_UPDATE_CONFIG_PER_POOL: 7e3,
|
|
554
554
|
VAULT_CANCEL_CONFIG_UPDATE: 75e3,
|
|
555
555
|
VAULT_SET_STATUS: 78e3,
|
|
556
556
|
VAULT_DEPOSIT: 26e4,
|
|
@@ -1068,6 +1068,167 @@ var QueryParamsResponse = {
|
|
|
1068
1068
|
return message;
|
|
1069
1069
|
}
|
|
1070
1070
|
};
|
|
1071
|
+
function createBaseQueryFeeFreeGasLimitsResponse() {
|
|
1072
|
+
return { gasLimits: [] };
|
|
1073
|
+
}
|
|
1074
|
+
var QueryFeeFreeGasLimitsResponse = {
|
|
1075
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
1076
|
+
for (const v of message.gasLimits) {
|
|
1077
|
+
FeeFreeGasLimit.encode(v, writer.uint32(10).fork()).join();
|
|
1078
|
+
}
|
|
1079
|
+
return writer;
|
|
1080
|
+
},
|
|
1081
|
+
decode(input, length) {
|
|
1082
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
1083
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
1084
|
+
const message = createBaseQueryFeeFreeGasLimitsResponse();
|
|
1085
|
+
while (reader.pos < end) {
|
|
1086
|
+
const tag = reader.uint32();
|
|
1087
|
+
switch (tag >>> 3) {
|
|
1088
|
+
case 1: {
|
|
1089
|
+
if (tag !== 10) {
|
|
1090
|
+
break;
|
|
1091
|
+
}
|
|
1092
|
+
message.gasLimits.push(FeeFreeGasLimit.decode(reader, reader.uint32()));
|
|
1093
|
+
continue;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1097
|
+
break;
|
|
1098
|
+
}
|
|
1099
|
+
reader.skip(tag & 7);
|
|
1100
|
+
}
|
|
1101
|
+
return message;
|
|
1102
|
+
},
|
|
1103
|
+
fromJSON(object2) {
|
|
1104
|
+
return {
|
|
1105
|
+
gasLimits: globalThis.Array.isArray(object2?.gasLimits) ? object2.gasLimits.map((e) => FeeFreeGasLimit.fromJSON(e)) : globalThis.Array.isArray(object2?.gas_limits) ? object2.gas_limits.map((e) => FeeFreeGasLimit.fromJSON(e)) : []
|
|
1106
|
+
};
|
|
1107
|
+
},
|
|
1108
|
+
toJSON(message) {
|
|
1109
|
+
const obj = {};
|
|
1110
|
+
if (message.gasLimits?.length) {
|
|
1111
|
+
obj.gasLimits = message.gasLimits.map((e) => FeeFreeGasLimit.toJSON(e));
|
|
1112
|
+
}
|
|
1113
|
+
return obj;
|
|
1114
|
+
},
|
|
1115
|
+
create(base) {
|
|
1116
|
+
return QueryFeeFreeGasLimitsResponse.fromPartial(base ?? {});
|
|
1117
|
+
},
|
|
1118
|
+
fromPartial(object2) {
|
|
1119
|
+
const message = createBaseQueryFeeFreeGasLimitsResponse();
|
|
1120
|
+
message.gasLimits = object2.gasLimits?.map((e) => FeeFreeGasLimit.fromPartial(e)) || [];
|
|
1121
|
+
return message;
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
function createBaseFeeFreeGasLimit() {
|
|
1125
|
+
return { msgTypeUrl: "", baseGasLimit: 0n, perUnitGasLimit: 0n, variant: "" };
|
|
1126
|
+
}
|
|
1127
|
+
var FeeFreeGasLimit = {
|
|
1128
|
+
encode(message, writer = new BinaryWriter4()) {
|
|
1129
|
+
if (message.msgTypeUrl !== "") {
|
|
1130
|
+
writer.uint32(10).string(message.msgTypeUrl);
|
|
1131
|
+
}
|
|
1132
|
+
if (message.baseGasLimit !== 0n) {
|
|
1133
|
+
if (BigInt.asUintN(64, message.baseGasLimit) !== message.baseGasLimit) {
|
|
1134
|
+
throw new globalThis.Error(
|
|
1135
|
+
"value provided for field message.baseGasLimit of type uint64 too large"
|
|
1136
|
+
);
|
|
1137
|
+
}
|
|
1138
|
+
writer.uint32(16).uint64(message.baseGasLimit);
|
|
1139
|
+
}
|
|
1140
|
+
if (message.perUnitGasLimit !== 0n) {
|
|
1141
|
+
if (BigInt.asUintN(64, message.perUnitGasLimit) !== message.perUnitGasLimit) {
|
|
1142
|
+
throw new globalThis.Error(
|
|
1143
|
+
"value provided for field message.perUnitGasLimit of type uint64 too large"
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
writer.uint32(24).uint64(message.perUnitGasLimit);
|
|
1147
|
+
}
|
|
1148
|
+
if (message.variant !== "") {
|
|
1149
|
+
writer.uint32(34).string(message.variant);
|
|
1150
|
+
}
|
|
1151
|
+
return writer;
|
|
1152
|
+
},
|
|
1153
|
+
decode(input, length) {
|
|
1154
|
+
const reader = input instanceof BinaryReader4 ? input : new BinaryReader4(input);
|
|
1155
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
1156
|
+
const message = createBaseFeeFreeGasLimit();
|
|
1157
|
+
while (reader.pos < end) {
|
|
1158
|
+
const tag = reader.uint32();
|
|
1159
|
+
switch (tag >>> 3) {
|
|
1160
|
+
case 1: {
|
|
1161
|
+
if (tag !== 10) {
|
|
1162
|
+
break;
|
|
1163
|
+
}
|
|
1164
|
+
message.msgTypeUrl = reader.string();
|
|
1165
|
+
continue;
|
|
1166
|
+
}
|
|
1167
|
+
case 2: {
|
|
1168
|
+
if (tag !== 16) {
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
message.baseGasLimit = reader.uint64();
|
|
1172
|
+
continue;
|
|
1173
|
+
}
|
|
1174
|
+
case 3: {
|
|
1175
|
+
if (tag !== 24) {
|
|
1176
|
+
break;
|
|
1177
|
+
}
|
|
1178
|
+
message.perUnitGasLimit = reader.uint64();
|
|
1179
|
+
continue;
|
|
1180
|
+
}
|
|
1181
|
+
case 4: {
|
|
1182
|
+
if (tag !== 34) {
|
|
1183
|
+
break;
|
|
1184
|
+
}
|
|
1185
|
+
message.variant = reader.string();
|
|
1186
|
+
continue;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1190
|
+
break;
|
|
1191
|
+
}
|
|
1192
|
+
reader.skip(tag & 7);
|
|
1193
|
+
}
|
|
1194
|
+
return message;
|
|
1195
|
+
},
|
|
1196
|
+
fromJSON(object2) {
|
|
1197
|
+
return {
|
|
1198
|
+
msgTypeUrl: isSet3(object2.msgTypeUrl) ? globalThis.String(object2.msgTypeUrl) : isSet3(object2.msg_type_url) ? globalThis.String(object2.msg_type_url) : "",
|
|
1199
|
+
baseGasLimit: isSet3(object2.baseGasLimit) ? BigInt(object2.baseGasLimit) : isSet3(object2.base_gas_limit) ? BigInt(object2.base_gas_limit) : 0n,
|
|
1200
|
+
perUnitGasLimit: isSet3(object2.perUnitGasLimit) ? BigInt(object2.perUnitGasLimit) : isSet3(object2.per_unit_gas_limit) ? BigInt(object2.per_unit_gas_limit) : 0n,
|
|
1201
|
+
variant: isSet3(object2.variant) ? globalThis.String(object2.variant) : ""
|
|
1202
|
+
};
|
|
1203
|
+
},
|
|
1204
|
+
toJSON(message) {
|
|
1205
|
+
const obj = {};
|
|
1206
|
+
if (message.msgTypeUrl !== "") {
|
|
1207
|
+
obj.msgTypeUrl = message.msgTypeUrl;
|
|
1208
|
+
}
|
|
1209
|
+
if (message.baseGasLimit !== 0n) {
|
|
1210
|
+
obj.baseGasLimit = message.baseGasLimit.toString();
|
|
1211
|
+
}
|
|
1212
|
+
if (message.perUnitGasLimit !== 0n) {
|
|
1213
|
+
obj.perUnitGasLimit = message.perUnitGasLimit.toString();
|
|
1214
|
+
}
|
|
1215
|
+
if (message.variant !== "") {
|
|
1216
|
+
obj.variant = message.variant;
|
|
1217
|
+
}
|
|
1218
|
+
return obj;
|
|
1219
|
+
},
|
|
1220
|
+
create(base) {
|
|
1221
|
+
return FeeFreeGasLimit.fromPartial(base ?? {});
|
|
1222
|
+
},
|
|
1223
|
+
fromPartial(object2) {
|
|
1224
|
+
const message = createBaseFeeFreeGasLimit();
|
|
1225
|
+
message.msgTypeUrl = object2.msgTypeUrl ?? "";
|
|
1226
|
+
message.baseGasLimit = object2.baseGasLimit ?? 0n;
|
|
1227
|
+
message.perUnitGasLimit = object2.perUnitGasLimit ?? 0n;
|
|
1228
|
+
message.variant = object2.variant ?? "";
|
|
1229
|
+
return message;
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1071
1232
|
function isSet3(value) {
|
|
1072
1233
|
return value !== null && value !== void 0;
|
|
1073
1234
|
}
|
|
@@ -28885,14 +29046,32 @@ function isSet55(value) {
|
|
|
28885
29046
|
}
|
|
28886
29047
|
|
|
28887
29048
|
// src/rest/ratelimit.ts
|
|
29049
|
+
var DEFAULT_FEE_FREE_RATE_LIMIT = 1;
|
|
28888
29050
|
function createRateLimitApi(context) {
|
|
28889
29051
|
return {
|
|
29052
|
+
// The gateway drops the leading "/" of a type URL in the path (it redirects
|
|
29053
|
+
// %2F away), so the config route finds nothing for a real type URL. This
|
|
29054
|
+
// answers what the route would: the rule from the params, else the default
|
|
29055
|
+
// limit for a fee-free message (x/accountx lists them with their gas), else
|
|
29056
|
+
// an empty config, which means the type is not limited.
|
|
28890
29057
|
async getRateLimitConfig(msgType) {
|
|
28891
|
-
|
|
29058
|
+
const typeUrl = msgType.startsWith("/") ? msgType : `/${msgType}`;
|
|
29059
|
+
const { params } = await fetchProtoJson(
|
|
28892
29060
|
context,
|
|
28893
|
-
|
|
28894
|
-
|
|
29061
|
+
"/ault/ratelimit/v1/params",
|
|
29062
|
+
QueryParamsResponse11
|
|
28895
29063
|
);
|
|
29064
|
+
const config = params?.rateLimitConfigs.find((entry) => entry.msgType === typeUrl);
|
|
29065
|
+
if (config) return QueryRateLimitConfigResponse.fromPartial({ config });
|
|
29066
|
+
const { gasLimits } = await fetchProtoJson(
|
|
29067
|
+
context,
|
|
29068
|
+
"/ault/accountx/v1/fee_free_gas_limits",
|
|
29069
|
+
QueryFeeFreeGasLimitsResponse
|
|
29070
|
+
);
|
|
29071
|
+
const feeFree = gasLimits.some((entry) => entry.msgTypeUrl === typeUrl);
|
|
29072
|
+
return QueryRateLimitConfigResponse.fromPartial({
|
|
29073
|
+
config: feeFree ? { msgType: typeUrl, limit: DEFAULT_FEE_FREE_RATE_LIMIT } : {}
|
|
29074
|
+
});
|
|
28896
29075
|
},
|
|
28897
29076
|
async getParams() {
|
|
28898
29077
|
return fetchProtoJson(context, "/ault/ratelimit/v1/params", QueryParamsResponse11);
|
|
@@ -31843,13 +32022,6 @@ function getPortfolioHoldings(address, options) {
|
|
|
31843
32022
|
method: "GET"
|
|
31844
32023
|
});
|
|
31845
32024
|
}
|
|
31846
|
-
function getPortfolioFlows(address, range, options) {
|
|
31847
|
-
const query = range ? `?range=${range}` : "";
|
|
31848
|
-
return dexFetch(`/api/v1/portfolio/${enc4(address)}/flows${query}`, {
|
|
31849
|
-
...options,
|
|
31850
|
-
method: "GET"
|
|
31851
|
-
});
|
|
31852
|
-
}
|
|
31853
32025
|
function getPortfolioPnl(address, range, options) {
|
|
31854
32026
|
const query = range ? `?range=${range}` : "";
|
|
31855
32027
|
return dexFetch(`/api/v1/portfolio/${enc4(address)}/pnl${query}`, {
|
|
@@ -31902,7 +32074,6 @@ function createDexApi(context) {
|
|
|
31902
32074
|
getBalance: bind(context, getBalance),
|
|
31903
32075
|
getStats: bind(context, getStats),
|
|
31904
32076
|
getPortfolioHoldings: bind(context, getPortfolioHoldings),
|
|
31905
|
-
getPortfolioFlows: bind(context, getPortfolioFlows),
|
|
31906
32077
|
getPortfolioPnl: bind(context, getPortfolioPnl),
|
|
31907
32078
|
getPortfolioTimeSeries: bind(context, getPortfolioTimeSeries),
|
|
31908
32079
|
getUDFConfig: bind(context, getUDFConfig),
|
|
@@ -38595,13 +38766,7 @@ function buildVaultManagerSurface(options, ctx) {
|
|
|
38595
38766
|
cache: createAccountCache()
|
|
38596
38767
|
});
|
|
38597
38768
|
const moduleCtx = { masterAddress: vaultAddress, exec, getGas: ctx.getGas };
|
|
38598
|
-
const {
|
|
38599
|
-
placeTwapOrder: _twap,
|
|
38600
|
-
placeConditionalOrder: _conditional,
|
|
38601
|
-
modifyConditionalOrders: _modifyConditional,
|
|
38602
|
-
placeGroupOrder: _group,
|
|
38603
|
-
...clob
|
|
38604
|
-
} = createAgentClobTxApi(moduleCtx);
|
|
38769
|
+
const { placeTwapOrder: _twap, ...clob } = createAgentClobTxApi(moduleCtx);
|
|
38605
38770
|
return {
|
|
38606
38771
|
address: deriveAgentAddress(options.agentPrivateKey),
|
|
38607
38772
|
vaultAddress,
|
|
@@ -40071,13 +40236,13 @@ var ListTradesResponseItem = zod.object({
|
|
|
40071
40236
|
"All numeric fields are canonical decimal strings \u2014 quantities at any\nmagnitude survive the JSON round-trip without rounding through\nfloat64. Consumers parse with their own bigdecimal.\n"
|
|
40072
40237
|
);
|
|
40073
40238
|
var ListTradesResponse = zod.array(ListTradesResponseItem);
|
|
40074
|
-
var getTradePathIdMax =
|
|
40239
|
+
var getTradePathIdMax = 125;
|
|
40075
40240
|
var getTradePathIdRegExp = new RegExp(
|
|
40076
|
-
"^(0|[1-9][0-9]*)-[0-9a-f]{32}-(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?$"
|
|
40241
|
+
"^(0|[1-9][0-9]*)-[0-9a-f]{32}-(0|[1-9][0-9]*)(\\.[0-9]*[1-9])?(-(0|[1-9][0-9]{0,9}))?$"
|
|
40077
40242
|
);
|
|
40078
40243
|
var GetTradeParams = zod.object({
|
|
40079
40244
|
id: zod.string().max(getTradePathIdMax).regex(getTradePathIdRegExp).describe(
|
|
40080
|
-
"Synthesized trade id in the form\n`<block_height>-<hex(order_id)>-<open_quantity>`, taken verbatim from
|
|
40245
|
+
"Synthesized trade id in the form\n`<block_height>-<hex(order_id)>-<open_quantity>`, or\n`<block_height>-<hex(order_id)>-<open_quantity>-<event_index>` from\nthe Ault v3.0.0-rc.4 upgrade height, taken verbatim from a REST\ntrade object's `id` field (not the WebSocket `tid`).\n"
|
|
40081
40246
|
)
|
|
40082
40247
|
});
|
|
40083
40248
|
var getTradeResponsePriceRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
|
|
@@ -40873,9 +41038,7 @@ var ListPerpMarketsResponseItem = zod.object({
|
|
|
40873
41038
|
takerFeeRate: zod.string(),
|
|
40874
41039
|
marginTiers: zod.array(
|
|
40875
41040
|
zod.object({
|
|
40876
|
-
notionalCap: zod.string().describe(
|
|
40877
|
-
'Upper notional bound of the tier in quote; "0" marks the unbounded last tier.'
|
|
40878
|
-
),
|
|
41041
|
+
notionalCap: zod.string().describe('Upper notional bound of the tier in quote; "0" marks the unbounded last tier.'),
|
|
40879
41042
|
maxLeverage: zod.number()
|
|
40880
41043
|
})
|
|
40881
41044
|
),
|
|
@@ -40905,9 +41068,7 @@ var GetPerpMarketResponse = zod.object({
|
|
|
40905
41068
|
takerFeeRate: zod.string(),
|
|
40906
41069
|
marginTiers: zod.array(
|
|
40907
41070
|
zod.object({
|
|
40908
|
-
notionalCap: zod.string().describe(
|
|
40909
|
-
'Upper notional bound of the tier in quote; "0" marks the unbounded last tier.'
|
|
40910
|
-
),
|
|
41071
|
+
notionalCap: zod.string().describe('Upper notional bound of the tier in quote; "0" marks the unbounded last tier.'),
|
|
40911
41072
|
maxLeverage: zod.number()
|
|
40912
41073
|
})
|
|
40913
41074
|
),
|
|
@@ -41006,7 +41167,9 @@ var ListPerpMarketTradesQueryParams = zod.object({
|
|
|
41006
41167
|
)
|
|
41007
41168
|
});
|
|
41008
41169
|
var ListPerpMarketTradesResponseItem = zod.object({
|
|
41009
|
-
id: zod.string().describe(
|
|
41170
|
+
id: zod.string().describe(
|
|
41171
|
+
"`<block_height>-<hex(order_id)>-<open_quantity>`, plus `-<event_index>` from the Ault v3.0.0-rc.4 upgrade height"
|
|
41172
|
+
),
|
|
41010
41173
|
timestamp: zod.number(),
|
|
41011
41174
|
marketId: zod.string(),
|
|
41012
41175
|
price: zod.string(),
|
|
@@ -42266,7 +42429,6 @@ export {
|
|
|
42266
42429
|
getPerpOrderbookQueryDepthDefault,
|
|
42267
42430
|
getPerpOrderbookQueryDepthMax,
|
|
42268
42431
|
getPerpTickerPathMarketIdRegExp,
|
|
42269
|
-
getPortfolioFlows,
|
|
42270
42432
|
getPortfolioHoldings,
|
|
42271
42433
|
getPortfolioPnl,
|
|
42272
42434
|
getPortfolioTimeSeries,
|