@aave/cli 4.1.0-next.2 → 4.1.0-next.4

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
@@ -20,7 +20,7 @@ $ npm install -g @aave/cli
20
20
  $ aave COMMAND
21
21
  running command...
22
22
  $ aave (--version)
23
- @aave/cli/4.1.0-next.2 darwin-arm64 node-v22.17.0
23
+ @aave/cli/4.1.0-next.4 darwin-arm64 node-v22.17.0
24
24
  $ aave --help [COMMAND]
25
25
  USAGE
26
26
  $ aave COMMAND
@@ -30,6 +30,7 @@ USAGE
30
30
  # Commands
31
31
  <!-- commands -->
32
32
  * [`aave hubs list`](#aave-hubs-list)
33
+ * [`aave reserves list`](#aave-reserves-list)
33
34
  * [`aave spokes list`](#aave-spokes-list)
34
35
 
35
36
  ## `aave hubs list`
@@ -50,7 +51,30 @@ DESCRIPTION
50
51
  List Aave v4 liquidity hubs
51
52
  ```
52
53
 
53
- _See code: [src/commands/hubs/list.ts](https://github.com/aave/aave-v4-sdk/blob/v4.1.0-next.2/src/commands/hubs/list.ts)_
54
+ _See code: [src/commands/hubs/list.ts](https://github.com/aave/aave-v4-sdk/blob/v4.1.0-next.4/src/commands/hubs/list.ts)_
55
+
56
+ ## `aave reserves list`
57
+
58
+ List Aave v4 reserves
59
+
60
+ ```
61
+ USAGE
62
+ $ aave reserves list [--json] [-s <spoke-id>] [-h <hub-id>] [--hub_address <evm-address> -c <chain-id>]
63
+
64
+ FLAGS
65
+ -c, --chain_id=<chain-id> The chain ID (e.g. 1, 137, 42161)
66
+ -h, --hub_id=<hub-id> The hub ID (e.g. SGVsbG8h…)
67
+ -s, --spoke_id=<spoke-id> The spoke ID (e.g. SGVsbG8h…)
68
+ --hub_address=<evm-address> The hub address (e.g. 0x123…)
69
+
70
+ GLOBAL FLAGS
71
+ --json Format output as json.
72
+
73
+ DESCRIPTION
74
+ List Aave v4 reserves
75
+ ```
76
+
77
+ _See code: [src/commands/reserves/list.ts](https://github.com/aave/aave-v4-sdk/blob/v4.1.0-next.4/src/commands/reserves/list.ts)_
54
78
 
55
79
  ## `aave spokes list`
56
80
 
@@ -72,5 +96,5 @@ DESCRIPTION
72
96
  List Aave v4 spokes
73
97
  ```
74
98
 
75
- _See code: [src/commands/spokes/list.ts](https://github.com/aave/aave-v4-sdk/blob/v4.1.0-next.2/src/commands/spokes/list.ts)_
99
+ _See code: [src/commands/spokes/list.ts](https://github.com/aave/aave-v4-sdk/blob/v4.1.0-next.4/src/commands/spokes/list.ts)_
76
100
  <!-- commandsstop -->
@@ -0,0 +1,16 @@
1
+ import { type Reserve } from '@aave/client';
2
+ import * as common from '../../common.js';
3
+ export default class ListReserves extends common.V4Command {
4
+ static description: string;
5
+ static flags: {
6
+ spoke_id: import("@oclif/core/interfaces").OptionFlag<import("@aave/graphql").SpokeId | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ hub_id: import("@oclif/core/interfaces").OptionFlag<import("@aave/graphql").HubId | undefined, import("@oclif/core/interfaces").CustomOptions>;
8
+ chain_id: import("@oclif/core/interfaces").OptionFlag<import("@aave/types").ChainId | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
+ hub_address: import("@oclif/core/interfaces").OptionFlag<import("@aave/types").EvmAddress | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ };
11
+ protected headers: {
12
+ value: string;
13
+ }[];
14
+ private getReservesRequest;
15
+ run(): Promise<Reserve[]>;
16
+ }
@@ -0,0 +1,118 @@
1
+ import { InvariantError, invariant, ok, ResultAsync, } from '@aave/client';
2
+ import { reserves } from '@aave/client/actions';
3
+ import * as common from '../../common.js';
4
+ function formatApy(apy, decimals = 4) {
5
+ return `${apy.normalized.toFixed(decimals)}%`;
6
+ }
7
+ export default class ListReserves extends common.V4Command {
8
+ static description = 'List Aave v4 reserves';
9
+ static flags = {
10
+ spoke_id: common.spoke({
11
+ required: false,
12
+ relationships: [
13
+ {
14
+ type: 'none',
15
+ flags: ['hub_id', 'chain_id', 'hub_address'],
16
+ },
17
+ ],
18
+ }),
19
+ hub_id: common.hub({
20
+ required: false,
21
+ relationships: [
22
+ {
23
+ type: 'none',
24
+ flags: ['spoke_id', 'chain_id', 'hub_address'],
25
+ },
26
+ ],
27
+ }),
28
+ chain_id: common.chain({
29
+ required: false,
30
+ relationships: [
31
+ {
32
+ type: 'none',
33
+ flags: ['spoke_id', 'hub_id'],
34
+ },
35
+ ],
36
+ }),
37
+ hub_address: common.address({
38
+ name: 'hub_address',
39
+ description: 'The hub address (e.g. 0x123…)',
40
+ relationships: [
41
+ {
42
+ type: 'none',
43
+ flags: ['spoke_id', 'hub_id'],
44
+ },
45
+ {
46
+ type: 'all',
47
+ flags: ['chain_id'],
48
+ },
49
+ ],
50
+ dependsOn: ['chain_id'],
51
+ }),
52
+ };
53
+ headers = [
54
+ { value: 'Asset' },
55
+ { value: 'Symbol' },
56
+ { value: 'Spoke' },
57
+ { value: 'Chain' },
58
+ { value: 'Supply APY' },
59
+ { value: 'Borrow APY' },
60
+ { value: 'Available Liquidity' },
61
+ { value: 'Total Borrowed' },
62
+ { value: 'Can Supply' },
63
+ { value: 'Can Borrow' },
64
+ { value: 'Collateral' },
65
+ { value: 'ID' },
66
+ ];
67
+ getReservesRequest() {
68
+ return ResultAsync.fromPromise(this.parse(ListReserves), (error) => new InvariantError(String(error))).andThen(({ flags }) => {
69
+ if (flags.spoke_id) {
70
+ return ok({
71
+ query: { spokeId: flags.spoke_id },
72
+ });
73
+ }
74
+ if (flags.hub_id) {
75
+ return ok({
76
+ query: { hubId: flags.hub_id },
77
+ });
78
+ }
79
+ if (flags.chain_id && flags.hub_address) {
80
+ return ok({
81
+ query: {
82
+ hub: {
83
+ address: flags.hub_address,
84
+ chainId: flags.chain_id,
85
+ },
86
+ },
87
+ });
88
+ }
89
+ if (flags.chain_id) {
90
+ return ok({
91
+ query: { chainIds: [flags.chain_id] },
92
+ });
93
+ }
94
+ invariant(false, 'You must provide --spoke_id, --hub_id, --chain_id, or (--hub_address and --chain_id)');
95
+ });
96
+ }
97
+ async run() {
98
+ const result = await this.getReservesRequest().andThen((request) => reserves(this.client, request));
99
+ if (result.isErr()) {
100
+ this.error(result.error);
101
+ }
102
+ this.display(result.value.map((item) => [
103
+ item.asset.underlying.info.name,
104
+ item.asset.underlying.info.symbol,
105
+ item.spoke.name,
106
+ `${item.chain.name} (${item.chain.chainId})`,
107
+ formatApy(item.summary.supplyApy),
108
+ formatApy(item.summary.borrowApy),
109
+ `${item.summary.supplied.exchange.symbol}${item.summary.supplied.exchange.value.toFixed(2)}`,
110
+ `${item.summary.borrowed.exchange.symbol}${item.summary.borrowed.exchange.value.toFixed(2)}`,
111
+ item.canSupply ? 'Yes' : 'No',
112
+ item.canBorrow ? 'Yes' : 'No',
113
+ item.canUseAsCollateral ? 'Yes' : 'No',
114
+ item.id,
115
+ ]));
116
+ return result.value;
117
+ }
118
+ }
package/dist/common.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AaveClient, type ChainId, type EvmAddress, type HubId } from '@aave/client';
1
+ import { AaveClient, type ChainId, type EvmAddress, type HubId, type SpokeId } from '@aave/client';
2
2
  import { Command } from '@oclif/core';
3
3
  import TtyTable from 'tty-table';
4
4
  export declare const chain: import("@oclif/core/interfaces").FlagDefinition<ChainId, import("@oclif/core/interfaces").CustomOptions, {
@@ -9,6 +9,10 @@ export declare const hub: import("@oclif/core/interfaces").FlagDefinition<HubId,
9
9
  multiple: false;
10
10
  requiredOrDefaulted: false;
11
11
  }>;
12
+ export declare const spoke: import("@oclif/core/interfaces").FlagDefinition<SpokeId, import("@oclif/core/interfaces").CustomOptions, {
13
+ multiple: false;
14
+ requiredOrDefaulted: false;
15
+ }>;
12
16
  export declare const address: import("@oclif/core/interfaces").FlagDefinition<EvmAddress, import("@oclif/core/interfaces").CustomOptions, {
13
17
  multiple: false;
14
18
  requiredOrDefaulted: false;
@@ -16,6 +20,11 @@ export declare const address: import("@oclif/core/interfaces").FlagDefinition<Ev
16
20
  export declare abstract class V4Command extends Command {
17
21
  protected headers: TtyTable.Header[];
18
22
  static enableJsonFlag: boolean;
23
+ static baseFlags: {
24
+ staging: import("@oclif/core/interfaces").BooleanFlag<boolean>;
25
+ };
19
26
  protected client: AaveClient;
27
+ init(): Promise<void>;
20
28
  protected display(rows: unknown[]): void;
29
+ protected toSuccessJson(result: unknown): unknown;
21
30
  }
package/dist/common.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AaveClient, chainId, evmAddress, hubId, } from '@aave/client';
1
+ import { AaveClient, chainId, evmAddress, hubId, production, spokeId, staging, } from '@aave/client';
2
2
  import { Command, Flags } from '@oclif/core';
3
3
  import TtyTable from 'tty-table';
4
4
  export const chain = Flags.custom({
@@ -15,16 +15,55 @@ export const hub = Flags.custom({
15
15
  helpValue: '<hub-id>',
16
16
  parse: async (input) => hubId(input),
17
17
  });
18
+ export const spoke = Flags.custom({
19
+ char: 's',
20
+ name: 'spoke',
21
+ description: 'The spoke ID (e.g. SGVsbG8h…)',
22
+ helpValue: '<spoke-id>',
23
+ parse: async (input) => spokeId(input),
24
+ });
18
25
  export const address = Flags.custom({
19
26
  parse: async (input) => evmAddress(input),
20
27
  helpValue: '<evm-address>',
21
28
  });
29
+ function convertBigIntsToStrings(obj) {
30
+ if (typeof obj === 'bigint') {
31
+ return obj.toString();
32
+ }
33
+ if (Array.isArray(obj)) {
34
+ return obj.map(convertBigIntsToStrings);
35
+ }
36
+ if (obj !== null && typeof obj === 'object') {
37
+ const result = {};
38
+ for (const [key, value] of Object.entries(obj)) {
39
+ result[key] = convertBigIntsToStrings(value);
40
+ }
41
+ return result;
42
+ }
43
+ return obj;
44
+ }
22
45
  export class V4Command extends Command {
23
46
  headers = [];
24
47
  static enableJsonFlag = true;
25
- client = AaveClient.create();
48
+ static baseFlags = {
49
+ staging: Flags.boolean({
50
+ hidden: true,
51
+ description: 'Use staging environment',
52
+ default: false,
53
+ }),
54
+ };
55
+ client;
56
+ async init() {
57
+ await super.init();
58
+ const { flags } = await this.parse(this.constructor);
59
+ const environment = flags.staging ? staging : production;
60
+ this.client = AaveClient.create({ environment });
61
+ }
26
62
  display(rows) {
27
63
  const out = TtyTable(this.headers, rows).render();
28
64
  this.log(out);
29
65
  }
66
+ toSuccessJson(result) {
67
+ return convertBigIntsToStrings(result);
68
+ }
30
69
  }
@@ -12,6 +12,13 @@
12
12
  "allowNo": false,
13
13
  "type": "boolean"
14
14
  },
15
+ "staging": {
16
+ "description": "Use staging environment",
17
+ "hidden": true,
18
+ "name": "staging",
19
+ "allowNo": false,
20
+ "type": "boolean"
21
+ },
15
22
  "chain": {
16
23
  "char": "c",
17
24
  "description": "The chain ID (e.g. 1, 137, 42161)",
@@ -38,6 +45,127 @@
38
45
  "list.js"
39
46
  ]
40
47
  },
48
+ "reserves:list": {
49
+ "aliases": [],
50
+ "args": {},
51
+ "description": "List Aave v4 reserves",
52
+ "flags": {
53
+ "json": {
54
+ "description": "Format output as json.",
55
+ "helpGroup": "GLOBAL",
56
+ "name": "json",
57
+ "allowNo": false,
58
+ "type": "boolean"
59
+ },
60
+ "staging": {
61
+ "description": "Use staging environment",
62
+ "hidden": true,
63
+ "name": "staging",
64
+ "allowNo": false,
65
+ "type": "boolean"
66
+ },
67
+ "spoke_id": {
68
+ "char": "s",
69
+ "description": "The spoke ID (e.g. SGVsbG8h…)",
70
+ "name": "spoke_id",
71
+ "relationships": [
72
+ {
73
+ "type": "none",
74
+ "flags": [
75
+ "hub_id",
76
+ "chain_id",
77
+ "hub_address"
78
+ ]
79
+ }
80
+ ],
81
+ "required": false,
82
+ "hasDynamicHelp": false,
83
+ "helpValue": "<spoke-id>",
84
+ "multiple": false,
85
+ "type": "option"
86
+ },
87
+ "hub_id": {
88
+ "char": "h",
89
+ "description": "The hub ID (e.g. SGVsbG8h…)",
90
+ "name": "hub_id",
91
+ "relationships": [
92
+ {
93
+ "type": "none",
94
+ "flags": [
95
+ "spoke_id",
96
+ "chain_id",
97
+ "hub_address"
98
+ ]
99
+ }
100
+ ],
101
+ "required": false,
102
+ "hasDynamicHelp": false,
103
+ "helpValue": "<hub-id>",
104
+ "multiple": false,
105
+ "type": "option"
106
+ },
107
+ "chain_id": {
108
+ "char": "c",
109
+ "description": "The chain ID (e.g. 1, 137, 42161)",
110
+ "name": "chain_id",
111
+ "relationships": [
112
+ {
113
+ "type": "none",
114
+ "flags": [
115
+ "spoke_id",
116
+ "hub_id"
117
+ ]
118
+ }
119
+ ],
120
+ "required": false,
121
+ "hasDynamicHelp": false,
122
+ "helpValue": "<chain-id>",
123
+ "multiple": false,
124
+ "type": "option"
125
+ },
126
+ "hub_address": {
127
+ "dependsOn": [
128
+ "chain_id"
129
+ ],
130
+ "description": "The hub address (e.g. 0x123…)",
131
+ "name": "hub_address",
132
+ "relationships": [
133
+ {
134
+ "type": "none",
135
+ "flags": [
136
+ "spoke_id",
137
+ "hub_id"
138
+ ]
139
+ },
140
+ {
141
+ "type": "all",
142
+ "flags": [
143
+ "chain_id"
144
+ ]
145
+ }
146
+ ],
147
+ "hasDynamicHelp": false,
148
+ "helpValue": "<evm-address>",
149
+ "multiple": false,
150
+ "type": "option"
151
+ }
152
+ },
153
+ "hasDynamicHelp": false,
154
+ "hiddenAliases": [],
155
+ "id": "reserves:list",
156
+ "pluginAlias": "@aave/cli",
157
+ "pluginName": "@aave/cli",
158
+ "pluginType": "core",
159
+ "strict": true,
160
+ "enableJsonFlag": true,
161
+ "isESM": true,
162
+ "relativePath": [
163
+ "dist",
164
+ "commands",
165
+ "reserves",
166
+ "list.js"
167
+ ]
168
+ },
41
169
  "spokes:list": {
42
170
  "aliases": [],
43
171
  "args": {},
@@ -50,6 +178,13 @@
50
178
  "allowNo": false,
51
179
  "type": "boolean"
52
180
  },
181
+ "staging": {
182
+ "description": "Use staging environment",
183
+ "hidden": true,
184
+ "name": "staging",
185
+ "allowNo": false,
186
+ "type": "boolean"
187
+ },
53
188
  "hub_id": {
54
189
  "char": "h",
55
190
  "description": "The hub ID (e.g. SGVsbG8h…)",
@@ -129,5 +264,5 @@
129
264
  ]
130
265
  }
131
266
  },
132
- "version": "4.1.0-next.2"
267
+ "version": "4.1.0-next.4"
133
268
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aave/cli",
3
- "version": "4.1.0-next.2",
3
+ "version": "4.1.0-next.4",
4
4
  "description": "CLI to interact with AaveKit API",
5
5
  "keywords": [
6
6
  "aave",
@@ -30,7 +30,7 @@
30
30
  "@oclif/plugin-help": "^6",
31
31
  "@oclif/plugin-plugins": "^5",
32
32
  "tty-table": "^5.0.0",
33
- "@aave/client": "4.0.0-next.9"
33
+ "@aave/client": "4.0.0-next.11"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@oclif/test": "^4",