@hightop/sdk 0.1.4 → 0.1.6

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 CHANGED
@@ -43,6 +43,7 @@ const client = new HightopAgentClient({
43
43
  })
44
44
 
45
45
  const self = await client.self.get()
46
+ const collateralOptions = await client.request('GET /v1/agent/borrow/collateral-options')
46
47
  const repay = await client.borrow.repay(
47
48
  { asset: 'GREEN', amount_usd: '10' },
48
49
  { idempotencyKey: createIdempotencyKey() },
@@ -62,6 +63,11 @@ const capabilities = await new HightopAgentClient({ baseUrl: 'https://api.highto
62
63
  Every catalogued `/v1/agent/*` endpoint is available through the generated typed request map:
63
64
 
64
65
  ```ts
66
+ const collateralOptions = await client.request('GET /v1/agent/borrow/collateral-options')
67
+ const usdcVault = collateralOptions.items.find(
68
+ (option) => option.source_type === 'earn_vault' && option.asset_symbol === 'USDC',
69
+ )
70
+
65
71
  const oneOff = await client.request(
66
72
  'POST /v1/agent/one-off-payments',
67
73
  {
@@ -75,6 +81,8 @@ const oneOff = await client.request(
75
81
  )
76
82
  ```
77
83
 
84
+ For `POST /v1/agent/borrow/collateral/add`, pass a collateral option `id` as `asset`. Vault-backed options use a vault contract address as the id, so callers should discover options instead of guessing from token symbols.
85
+
78
86
  The generated package artifact exports:
79
87
 
80
88
  ```ts
package/dist/client.js CHANGED
@@ -230,6 +230,7 @@ export class HightopAgentClient {
230
230
  while (Date.now() <= deadline) {
231
231
  const remainingMs = Math.max(1, deadline - Date.now());
232
232
  const pollRequestTimeoutMs = Math.min(this.timeoutMs, remainingMs);
233
+ const pollBoundByWaitDeadline = pollRequestTimeoutMs === remainingMs;
233
234
  let response;
234
235
  try {
235
236
  response = await this.operations.get(id, undefined, {
@@ -239,7 +240,9 @@ export class HightopAgentClient {
239
240
  });
240
241
  }
241
242
  catch (error) {
242
- if (Date.now() >= deadline && error instanceof HightopAgentSDKError && error.code === 'request_timeout') {
243
+ if (error instanceof HightopAgentSDKError &&
244
+ error.code === 'request_timeout' &&
245
+ (pollBoundByWaitDeadline || Date.now() >= deadline)) {
243
246
  break;
244
247
  }
245
248
  throw error;
@@ -1,4 +1,4 @@
1
- export declare const AGENT_API_CONTRACT_VERSION = "1.6.0";
1
+ export declare const AGENT_API_CONTRACT_VERSION = "1.7.0";
2
2
  export type EthAddress = `0x${string}`;
3
3
  export type AgentErrorDetailsByCode = {
4
4
  idempotency_request_in_progress: {
@@ -34,6 +34,12 @@ export type AgentErrorDetailsByCode = {
34
34
  period: 'rolling_30d' | 'active';
35
35
  } | {
36
36
  max_endpoints: number;
37
+ } | {
38
+ cap: number;
39
+ observed: number;
40
+ period: 'manager_period';
41
+ cap_kind: 'max_num_swaps_per_period';
42
+ quote_id: string;
37
43
  };
38
44
  ltv_too_high: {
39
45
  current_ltv: string;
@@ -115,6 +121,32 @@ export type AgentApiSelfUsageResponse = {
115
121
  operations_submitted_today?: number;
116
122
  };
117
123
  };
124
+ export type AgentApiSelfLimitsResponse = {
125
+ ok: true;
126
+ spend_limits: {
127
+ per_tx_usd: string | null;
128
+ per_period_usd: string | null;
129
+ lifetime_usd: string | null;
130
+ max_txs_per_period: number | null;
131
+ tx_cooldown_blocks: number | null;
132
+ fail_on_zero_price: boolean;
133
+ };
134
+ swap_limits: {
135
+ max_slippage_bps: number | null;
136
+ max_swaps_per_period: number | null;
137
+ };
138
+ permissions: {
139
+ operation_types: Array<'payment' | 'conversion' | 'earn.deposit' | 'earn.withdraw' | 'earn.move' | 'earn.rewards_claim' | 'debt.borrow' | 'debt.repay' | 'debt.deleverage' | 'collateral.add' | 'collateral.remove' | 'trusted_destination.confirm' | 'trusted_destination.cancel' | 'trusted_destination.remove' | 'withdrawal.bank' | 'withdrawal.crypto' | 'one_off_payment.create'>;
140
+ cannot: Array<'payment' | 'conversion' | 'earn.deposit' | 'earn.withdraw' | 'earn.move' | 'earn.rewards_claim' | 'debt.borrow' | 'debt.repay' | 'debt.deleverage' | 'collateral.add' | 'collateral.remove' | 'trusted_destination.confirm' | 'trusted_destination.cancel' | 'trusted_destination.remove' | 'withdrawal.bank' | 'withdrawal.crypto' | 'one_off_payment.create'>;
141
+ };
142
+ current_usage: {
143
+ txs_in_period: number;
144
+ spent_in_period_usd: string;
145
+ swaps_in_period: number;
146
+ total_txs: number;
147
+ total_spent_usd: string;
148
+ };
149
+ };
118
150
  export type AgentApiCapabilitiesResponse = {
119
151
  ok: true;
120
152
  api_version: '1.0';
@@ -592,6 +624,30 @@ export type AgentApiCollateralResponse = {
592
624
  next_cursor: string | null;
593
625
  has_more: boolean;
594
626
  };
627
+ export type AgentApiCollateralOptionsResponse = {
628
+ ok: true;
629
+ items: Array<{
630
+ id: string;
631
+ asset_symbol: string;
632
+ asset_display_name: string;
633
+ asset_address: string;
634
+ source_type: 'cash' | 'earn_vault';
635
+ vault_id?: string;
636
+ vault_name?: string;
637
+ protocol_id?: string;
638
+ protocol_name?: string;
639
+ amount: string;
640
+ amount_usd: string;
641
+ ltv: string;
642
+ max_ltv: string;
643
+ borrow_power_usd: string;
644
+ increases_borrow_capacity: boolean;
645
+ apy?: string;
646
+ allowed: true;
647
+ }>;
648
+ next_cursor: string | null;
649
+ has_more: boolean;
650
+ };
595
651
  export type AgentApiBorrowRepayRequest = {
596
652
  asset: 'GREEN' | '0xd1Eac76497D06Cf15475A5e3984D5bC03de7C707';
597
653
  repay_all?: boolean;
@@ -668,6 +724,7 @@ export type AgentApiSimulateRequest = {
668
724
  method: 'POST' | 'PATCH' | 'DELETE';
669
725
  path: string;
670
726
  body: unknown;
727
+ depth?: 'static' | 'policy' | 'onchain';
671
728
  };
672
729
  export type AgentApiSimulateResponse = {
673
730
  ok: true;
@@ -1014,6 +1071,21 @@ export declare const agentApiEndpoints: readonly [{
1014
1071
  readonly idempotencyRequired: false;
1015
1072
  readonly routeClass: "read";
1016
1073
  readonly description: "Return current Agent API rate-limit and usage state.";
1074
+ }, {
1075
+ readonly key: "GET /v1/agent/self/limits";
1076
+ readonly method: "GET";
1077
+ readonly path: "/v1/agent/self/limits";
1078
+ readonly pathParams: readonly [];
1079
+ readonly queryParams: readonly [];
1080
+ readonly bodyParams: readonly [];
1081
+ readonly requestSchema: null;
1082
+ readonly bodySchema: null;
1083
+ readonly responseSchema: "agentApiSelfLimitsResponse";
1084
+ readonly requestType: null;
1085
+ readonly responseType: "AgentApiSelfLimitsResponse";
1086
+ readonly idempotencyRequired: false;
1087
+ readonly routeClass: "read";
1088
+ readonly description: "Return the authenticated agent's configured spend limits and current-period usage.";
1017
1089
  }, {
1018
1090
  readonly key: "GET /v1/agent/capabilities";
1019
1091
  readonly method: "GET";
@@ -1554,6 +1626,21 @@ export declare const agentApiEndpoints: readonly [{
1554
1626
  readonly idempotencyRequired: false;
1555
1627
  readonly routeClass: "read";
1556
1628
  readonly description: "List collateral for the authenticated agent wallet.";
1629
+ }, {
1630
+ readonly key: "GET /v1/agent/borrow/collateral-options";
1631
+ readonly method: "GET";
1632
+ readonly path: "/v1/agent/borrow/collateral-options";
1633
+ readonly pathParams: readonly [];
1634
+ readonly queryParams: readonly ["cursor", "limit"];
1635
+ readonly bodyParams: readonly [];
1636
+ readonly requestSchema: "agentApiResourceListQuery";
1637
+ readonly bodySchema: null;
1638
+ readonly responseSchema: "agentApiCollateralOptionsResponse";
1639
+ readonly requestType: "AgentApiResourceListQuery";
1640
+ readonly responseType: "AgentApiCollateralOptionsResponse";
1641
+ readonly idempotencyRequired: false;
1642
+ readonly routeClass: "read";
1643
+ readonly description: "List addable collateral options for the authenticated agent wallet.";
1557
1644
  }, {
1558
1645
  readonly key: "POST /v1/agent/borrow/repay";
1559
1646
  readonly method: "POST";
@@ -1785,7 +1872,7 @@ export declare const agentApiEndpoints: readonly [{
1785
1872
  readonly path: "/v1/agent/simulate";
1786
1873
  readonly pathParams: readonly [];
1787
1874
  readonly queryParams: readonly [];
1788
- readonly bodyParams: readonly ["method", "path", "body"];
1875
+ readonly bodyParams: readonly ["method", "path", "body", "depth"];
1789
1876
  readonly requestSchema: "agentApiSimulateRequest";
1790
1877
  readonly bodySchema: "agentApiSimulateRequest";
1791
1878
  readonly responseSchema: "agentApiSimulateResponse";
@@ -1968,6 +2055,7 @@ export type AgentApiPathParams = Record<string, AgentApiPathParamValue>;
1968
2055
  export type AgentApiEndpointRequestMap = {
1969
2056
  readonly 'GET /v1/agent/self': undefined;
1970
2057
  readonly 'GET /v1/agent/self/usage': undefined;
2058
+ readonly 'GET /v1/agent/self/limits': undefined;
1971
2059
  readonly 'GET /v1/agent/capabilities': undefined;
1972
2060
  readonly 'GET /v1/agent/capabilities.json': undefined;
1973
2061
  readonly 'GET /v1/agent/account': undefined;
@@ -2016,6 +2104,7 @@ export type AgentApiEndpointRequestMap = {
2016
2104
  readonly 'GET /v1/agent/borrow': undefined;
2017
2105
  readonly 'POST /v1/agent/borrow': AgentApiBorrowRequest;
2018
2106
  readonly 'GET /v1/agent/borrow/collateral': AgentApiResourceListQuery;
2107
+ readonly 'GET /v1/agent/borrow/collateral-options': AgentApiResourceListQuery;
2019
2108
  readonly 'POST /v1/agent/borrow/repay': AgentApiBorrowRepayRequest;
2020
2109
  readonly 'POST /v1/agent/borrow/deleverage': AgentApiDeleverageRequest;
2021
2110
  readonly 'POST /v1/agent/borrow/collateral/add': AgentApiCollateralAddRequest;
@@ -2071,6 +2160,7 @@ export type AgentApiEndpointRequestMap = {
2071
2160
  export type AgentApiEndpointResponseMap = {
2072
2161
  readonly 'GET /v1/agent/self': AgentApiSelfResponse;
2073
2162
  readonly 'GET /v1/agent/self/usage': AgentApiSelfUsageResponse;
2163
+ readonly 'GET /v1/agent/self/limits': AgentApiSelfLimitsResponse;
2074
2164
  readonly 'GET /v1/agent/capabilities': AgentApiCapabilitiesResponse;
2075
2165
  readonly 'GET /v1/agent/capabilities.json': AgentApiCapabilitiesResponse;
2076
2166
  readonly 'GET /v1/agent/account': AgentApiAccountResponse;
@@ -2107,6 +2197,7 @@ export type AgentApiEndpointResponseMap = {
2107
2197
  readonly 'GET /v1/agent/borrow': AgentApiBorrowResponse;
2108
2198
  readonly 'POST /v1/agent/borrow': AgentApiWriteResponse;
2109
2199
  readonly 'GET /v1/agent/borrow/collateral': AgentApiCollateralResponse;
2200
+ readonly 'GET /v1/agent/borrow/collateral-options': AgentApiCollateralOptionsResponse;
2110
2201
  readonly 'POST /v1/agent/borrow/repay': AgentApiWriteResponse;
2111
2202
  readonly 'POST /v1/agent/borrow/deleverage': AgentApiWriteResponse;
2112
2203
  readonly 'POST /v1/agent/borrow/collateral/add': AgentApiWriteResponse;
@@ -3,7 +3,7 @@
3
3
  // Generated by scripts/generateAgentPackageSdk.ts
4
4
  // ═══════════════════════════════════════════════════════════════════════════
5
5
  /* eslint-disable */
6
- export const AGENT_API_CONTRACT_VERSION = '1.6.0';
6
+ export const AGENT_API_CONTRACT_VERSION = '1.7.0';
7
7
  function isAgentSdkRecord(value) {
8
8
  return typeof value === 'object' && value !== null && !Array.isArray(value);
9
9
  }
@@ -30,7 +30,13 @@ export const agentErrorDetailsValidators = {
30
30
  typeof value['cap'] === 'number' &&
31
31
  typeof value['observed'] === 'number' &&
32
32
  ['rolling_30d', 'active'].includes(value['period'])) ||
33
- (isAgentSdkRecord(value) && typeof value['max_endpoints'] === 'number'),
33
+ (isAgentSdkRecord(value) && typeof value['max_endpoints'] === 'number') ||
34
+ (isAgentSdkRecord(value) &&
35
+ typeof value['cap'] === 'number' &&
36
+ typeof value['observed'] === 'number' &&
37
+ ['manager_period'].includes(value['period']) &&
38
+ ['max_num_swaps_per_period'].includes(value['cap_kind']) &&
39
+ typeof value['quote_id'] === 'string'),
34
40
  ltv_too_high: (value) => isAgentSdkRecord(value) &&
35
41
  typeof value['current_ltv'] === 'string' &&
36
42
  typeof value['estimated_ltv_after'] === 'string' &&
@@ -129,6 +135,22 @@ export const agentApiEndpoints = [
129
135
  routeClass: 'read',
130
136
  description: 'Return current Agent API rate-limit and usage state.',
131
137
  },
138
+ {
139
+ key: 'GET /v1/agent/self/limits',
140
+ method: 'GET',
141
+ path: '/v1/agent/self/limits',
142
+ pathParams: [],
143
+ queryParams: [],
144
+ bodyParams: [],
145
+ requestSchema: null,
146
+ bodySchema: null,
147
+ responseSchema: 'agentApiSelfLimitsResponse',
148
+ requestType: null,
149
+ responseType: 'AgentApiSelfLimitsResponse',
150
+ idempotencyRequired: false,
151
+ routeClass: 'read',
152
+ description: "Return the authenticated agent's configured spend limits and current-period usage.",
153
+ },
132
154
  {
133
155
  key: 'GET /v1/agent/capabilities',
134
156
  method: 'GET',
@@ -705,6 +727,22 @@ export const agentApiEndpoints = [
705
727
  routeClass: 'read',
706
728
  description: 'List collateral for the authenticated agent wallet.',
707
729
  },
730
+ {
731
+ key: 'GET /v1/agent/borrow/collateral-options',
732
+ method: 'GET',
733
+ path: '/v1/agent/borrow/collateral-options',
734
+ pathParams: [],
735
+ queryParams: ['cursor', 'limit'],
736
+ bodyParams: [],
737
+ requestSchema: 'agentApiResourceListQuery',
738
+ bodySchema: null,
739
+ responseSchema: 'agentApiCollateralOptionsResponse',
740
+ requestType: 'AgentApiResourceListQuery',
741
+ responseType: 'AgentApiCollateralOptionsResponse',
742
+ idempotencyRequired: false,
743
+ routeClass: 'read',
744
+ description: 'List addable collateral options for the authenticated agent wallet.',
745
+ },
708
746
  {
709
747
  key: 'POST /v1/agent/borrow/repay',
710
748
  method: 'POST',
@@ -966,7 +1004,7 @@ export const agentApiEndpoints = [
966
1004
  path: '/v1/agent/simulate',
967
1005
  pathParams: [],
968
1006
  queryParams: [],
969
- bodyParams: ['method', 'path', 'body'],
1007
+ bodyParams: ['method', 'path', 'body', 'depth'],
970
1008
  requestSchema: 'agentApiSimulateRequest',
971
1009
  bodySchema: 'agentApiSimulateRequest',
972
1010
  responseSchema: 'agentApiSimulateResponse',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hightop/sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",