ault-sdk-ts 0.13.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/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.13.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: 2e3,
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: 5e3,
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
- return fetchProtoJson(
29058
+ const typeUrl = msgType.startsWith("/") ? msgType : `/${msgType}`;
29059
+ const { params } = await fetchProtoJson(
29060
+ context,
29061
+ "/ault/ratelimit/v1/params",
29062
+ QueryParamsResponse11
29063
+ );
29064
+ const config = params?.rateLimitConfigs.find((entry) => entry.msgType === typeUrl);
29065
+ if (config) return QueryRateLimitConfigResponse.fromPartial({ config });
29066
+ const { gasLimits } = await fetchProtoJson(
28892
29067
  context,
28893
- `/ault/ratelimit/v1/config/${encodeURIComponent(msgType)}`,
28894
- QueryRateLimitConfigResponse
29068
+ "/ault/accountx/v1/fee_free_gas_limits",
29069
+ QueryFeeFreeGasLimitsResponse
28895
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);
@@ -38587,13 +38766,7 @@ function buildVaultManagerSurface(options, ctx) {
38587
38766
  cache: createAccountCache()
38588
38767
  });
38589
38768
  const moduleCtx = { masterAddress: vaultAddress, exec, getGas: ctx.getGas };
38590
- const {
38591
- placeTwapOrder: _twap,
38592
- placeConditionalOrder: _conditional,
38593
- modifyConditionalOrders: _modifyConditional,
38594
- placeGroupOrder: _group,
38595
- ...clob
38596
- } = createAgentClobTxApi(moduleCtx);
38769
+ const { placeTwapOrder: _twap, ...clob } = createAgentClobTxApi(moduleCtx);
38597
38770
  return {
38598
38771
  address: deriveAgentAddress(options.agentPrivateKey),
38599
38772
  vaultAddress,
@@ -40063,13 +40236,13 @@ var ListTradesResponseItem = zod.object({
40063
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"
40064
40237
  );
40065
40238
  var ListTradesResponse = zod.array(ListTradesResponseItem);
40066
- var getTradePathIdMax = 114;
40239
+ var getTradePathIdMax = 125;
40067
40240
  var getTradePathIdRegExp = new RegExp(
40068
- "^(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}))?$"
40069
40242
  );
40070
40243
  var GetTradeParams = zod.object({
40071
40244
  id: zod.string().max(getTradePathIdMax).regex(getTradePathIdRegExp).describe(
40072
- "Synthesized trade id in the form\n`<block_height>-<hex(order_id)>-<open_quantity>`, taken verbatim from\na REST trade object's `id` field (not the WebSocket `tid`).\n"
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"
40073
40246
  )
40074
40247
  });
40075
40248
  var getTradeResponsePriceRegExp = new RegExp("^-?\\d+(\\.\\d+)?$");
@@ -40865,9 +41038,7 @@ var ListPerpMarketsResponseItem = zod.object({
40865
41038
  takerFeeRate: zod.string(),
40866
41039
  marginTiers: zod.array(
40867
41040
  zod.object({
40868
- notionalCap: zod.string().describe(
40869
- 'Upper notional bound of the tier in quote; "0" marks the unbounded last tier.'
40870
- ),
41041
+ notionalCap: zod.string().describe('Upper notional bound of the tier in quote; "0" marks the unbounded last tier.'),
40871
41042
  maxLeverage: zod.number()
40872
41043
  })
40873
41044
  ),
@@ -40897,9 +41068,7 @@ var GetPerpMarketResponse = zod.object({
40897
41068
  takerFeeRate: zod.string(),
40898
41069
  marginTiers: zod.array(
40899
41070
  zod.object({
40900
- notionalCap: zod.string().describe(
40901
- 'Upper notional bound of the tier in quote; "0" marks the unbounded last tier.'
40902
- ),
41071
+ notionalCap: zod.string().describe('Upper notional bound of the tier in quote; "0" marks the unbounded last tier.'),
40903
41072
  maxLeverage: zod.number()
40904
41073
  })
40905
41074
  ),
@@ -40998,7 +41167,9 @@ var ListPerpMarketTradesQueryParams = zod.object({
40998
41167
  )
40999
41168
  });
41000
41169
  var ListPerpMarketTradesResponseItem = zod.object({
41001
- id: zod.string().describe("`<block_height>-<hex(order_id)>-<open_quantity>`"),
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
+ ),
41002
41173
  timestamp: zod.number(),
41003
41174
  marketId: zod.string(),
41004
41175
  price: zod.string(),