@hightop/sdk 0.1.4 → 0.1.5
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 +8 -0
- package/dist/generated/agent-api.d.ts +47 -0
- package/dist/generated/agent-api.js +23 -1
- package/package.json +1 -1
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
|
|
@@ -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;
|
|
@@ -592,6 +598,30 @@ export type AgentApiCollateralResponse = {
|
|
|
592
598
|
next_cursor: string | null;
|
|
593
599
|
has_more: boolean;
|
|
594
600
|
};
|
|
601
|
+
export type AgentApiCollateralOptionsResponse = {
|
|
602
|
+
ok: true;
|
|
603
|
+
items: Array<{
|
|
604
|
+
id: string;
|
|
605
|
+
asset_symbol: string;
|
|
606
|
+
asset_display_name: string;
|
|
607
|
+
asset_address: string;
|
|
608
|
+
source_type: 'cash' | 'earn_vault';
|
|
609
|
+
vault_id?: string;
|
|
610
|
+
vault_name?: string;
|
|
611
|
+
protocol_id?: string;
|
|
612
|
+
protocol_name?: string;
|
|
613
|
+
amount: string;
|
|
614
|
+
amount_usd: string;
|
|
615
|
+
ltv: string;
|
|
616
|
+
max_ltv: string;
|
|
617
|
+
borrow_power_usd: string;
|
|
618
|
+
increases_borrow_capacity: boolean;
|
|
619
|
+
apy?: string;
|
|
620
|
+
allowed: true;
|
|
621
|
+
}>;
|
|
622
|
+
next_cursor: string | null;
|
|
623
|
+
has_more: boolean;
|
|
624
|
+
};
|
|
595
625
|
export type AgentApiBorrowRepayRequest = {
|
|
596
626
|
asset: 'GREEN' | '0xd1Eac76497D06Cf15475A5e3984D5bC03de7C707';
|
|
597
627
|
repay_all?: boolean;
|
|
@@ -1554,6 +1584,21 @@ export declare const agentApiEndpoints: readonly [{
|
|
|
1554
1584
|
readonly idempotencyRequired: false;
|
|
1555
1585
|
readonly routeClass: "read";
|
|
1556
1586
|
readonly description: "List collateral for the authenticated agent wallet.";
|
|
1587
|
+
}, {
|
|
1588
|
+
readonly key: "GET /v1/agent/borrow/collateral-options";
|
|
1589
|
+
readonly method: "GET";
|
|
1590
|
+
readonly path: "/v1/agent/borrow/collateral-options";
|
|
1591
|
+
readonly pathParams: readonly [];
|
|
1592
|
+
readonly queryParams: readonly ["cursor", "limit"];
|
|
1593
|
+
readonly bodyParams: readonly [];
|
|
1594
|
+
readonly requestSchema: "agentApiResourceListQuery";
|
|
1595
|
+
readonly bodySchema: null;
|
|
1596
|
+
readonly responseSchema: "agentApiCollateralOptionsResponse";
|
|
1597
|
+
readonly requestType: "AgentApiResourceListQuery";
|
|
1598
|
+
readonly responseType: "AgentApiCollateralOptionsResponse";
|
|
1599
|
+
readonly idempotencyRequired: false;
|
|
1600
|
+
readonly routeClass: "read";
|
|
1601
|
+
readonly description: "List addable collateral options for the authenticated agent wallet.";
|
|
1557
1602
|
}, {
|
|
1558
1603
|
readonly key: "POST /v1/agent/borrow/repay";
|
|
1559
1604
|
readonly method: "POST";
|
|
@@ -2016,6 +2061,7 @@ export type AgentApiEndpointRequestMap = {
|
|
|
2016
2061
|
readonly 'GET /v1/agent/borrow': undefined;
|
|
2017
2062
|
readonly 'POST /v1/agent/borrow': AgentApiBorrowRequest;
|
|
2018
2063
|
readonly 'GET /v1/agent/borrow/collateral': AgentApiResourceListQuery;
|
|
2064
|
+
readonly 'GET /v1/agent/borrow/collateral-options': AgentApiResourceListQuery;
|
|
2019
2065
|
readonly 'POST /v1/agent/borrow/repay': AgentApiBorrowRepayRequest;
|
|
2020
2066
|
readonly 'POST /v1/agent/borrow/deleverage': AgentApiDeleverageRequest;
|
|
2021
2067
|
readonly 'POST /v1/agent/borrow/collateral/add': AgentApiCollateralAddRequest;
|
|
@@ -2107,6 +2153,7 @@ export type AgentApiEndpointResponseMap = {
|
|
|
2107
2153
|
readonly 'GET /v1/agent/borrow': AgentApiBorrowResponse;
|
|
2108
2154
|
readonly 'POST /v1/agent/borrow': AgentApiWriteResponse;
|
|
2109
2155
|
readonly 'GET /v1/agent/borrow/collateral': AgentApiCollateralResponse;
|
|
2156
|
+
readonly 'GET /v1/agent/borrow/collateral-options': AgentApiCollateralOptionsResponse;
|
|
2110
2157
|
readonly 'POST /v1/agent/borrow/repay': AgentApiWriteResponse;
|
|
2111
2158
|
readonly 'POST /v1/agent/borrow/deleverage': AgentApiWriteResponse;
|
|
2112
2159
|
readonly 'POST /v1/agent/borrow/collateral/add': AgentApiWriteResponse;
|
|
@@ -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' &&
|
|
@@ -705,6 +711,22 @@ export const agentApiEndpoints = [
|
|
|
705
711
|
routeClass: 'read',
|
|
706
712
|
description: 'List collateral for the authenticated agent wallet.',
|
|
707
713
|
},
|
|
714
|
+
{
|
|
715
|
+
key: 'GET /v1/agent/borrow/collateral-options',
|
|
716
|
+
method: 'GET',
|
|
717
|
+
path: '/v1/agent/borrow/collateral-options',
|
|
718
|
+
pathParams: [],
|
|
719
|
+
queryParams: ['cursor', 'limit'],
|
|
720
|
+
bodyParams: [],
|
|
721
|
+
requestSchema: 'agentApiResourceListQuery',
|
|
722
|
+
bodySchema: null,
|
|
723
|
+
responseSchema: 'agentApiCollateralOptionsResponse',
|
|
724
|
+
requestType: 'AgentApiResourceListQuery',
|
|
725
|
+
responseType: 'AgentApiCollateralOptionsResponse',
|
|
726
|
+
idempotencyRequired: false,
|
|
727
|
+
routeClass: 'read',
|
|
728
|
+
description: 'List addable collateral options for the authenticated agent wallet.',
|
|
729
|
+
},
|
|
708
730
|
{
|
|
709
731
|
key: 'POST /v1/agent/borrow/repay',
|
|
710
732
|
method: 'POST',
|