@augustdigital/sdk 9.9.0 → 9.9.1

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.
@@ -3,4 +3,4 @@
3
3
  * Generated during publish from package.json version
4
4
  * This file is gitignored and created at publish time
5
5
  */
6
- export declare const SDK_VERSION = "9.9.0";
6
+ export declare const SDK_VERSION = "9.9.1";
@@ -6,5 +6,5 @@ exports.SDK_VERSION = void 0;
6
6
  * Generated during publish from package.json version
7
7
  * This file is gitignored and created at publish time
8
8
  */
9
- exports.SDK_VERSION = '9.9.0';
9
+ exports.SDK_VERSION = '9.9.1';
10
10
  //# sourceMappingURL=version.js.map
@@ -117,6 +117,7 @@ export declare const WEBSERVER_ENDPOINTS: {
117
117
  summary: (vaultAddress: IAddress) => string;
118
118
  withdrawals: (chain: string, vaultAddress: IAddress) => string;
119
119
  debank: (vaultAddress: IAddress) => string;
120
+ octav: (vaultAddress: IAddress) => string;
120
121
  userHistory: (vaultAddress: IAddress, wallet: IAddress) => string;
121
122
  archivedVaults: string;
122
123
  };
@@ -184,6 +184,7 @@ exports.WEBSERVER_ENDPOINTS = {
184
184
  summary: (vaultAddress) => `/tokenized_vault/vault_summary/${(0, ethers_1.getAddress)(vaultAddress)}`,
185
185
  withdrawals: (chain, vaultAddress) => `/withdrawals/${chain}/${(0, ethers_1.getAddress)(vaultAddress)}`,
186
186
  debank: (vaultAddress) => `/tokenized_vault/${(0, ethers_1.getAddress)(vaultAddress)}/debank`,
187
+ octav: (vaultAddress) => `/tokenized_vault/${subaccountSegment(vaultAddress)}/octav`,
187
188
  // Mongo-backed deposit/withdraw history for archived vaults whose
188
189
  // subgraph has been (or will be) retired. See fetchArchivedVaults.
189
190
  userHistory: (vaultAddress, wallet) => `/upshift/vault_history/${(0, ethers_1.getAddress)(vaultAddress)}?wallet=${(0, ethers_1.getAddress)(wallet)}`,
@@ -641,11 +641,14 @@ async function getVaultAllocations(vault, options, tokenizedVault) {
641
641
  // afterwards, and a borrower on a chain with portfolio coverage would otherwise
642
642
  // have its rows silently dropped rather than double-counted.
643
643
  let untangledTokenCount = 0;
644
+ let vaultOctav;
644
645
  const borrowerPortfolioFetchers = {
645
646
  solana: async (borrower) => {
646
- const portfolios = await (0, octavfi_1.fetchOctavfiPortfolios)([borrower]);
647
- return portfolios.length > 0
648
- ? (0, octavfi_1.transformOctavfiToDebank)(portfolios[0])
647
+ vaultOctav ??= (0, octavfi_1.fetchVaultOctavResponse)(vault, options?.headers);
648
+ const response = await vaultOctav;
649
+ const portfolio = response ? response[borrower] : undefined;
650
+ return portfolio && !('error' in portfolio)
651
+ ? (0, octavfi_1.transformOctavfiToDebank)(portfolio)
649
652
  : null;
650
653
  },
651
654
  };
package/lib/sdk.d.ts CHANGED
@@ -29074,6 +29074,7 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
29074
29074
  summary: (vaultAddress: IAddress) => string;
29075
29075
  withdrawals: (chain: string, vaultAddress: IAddress) => string;
29076
29076
  debank: (vaultAddress: IAddress) => string;
29077
+ octav: (vaultAddress: IAddress) => string;
29077
29078
  userHistory: (vaultAddress: IAddress, wallet: IAddress) => string;
29078
29079
  archivedVaults: string;
29079
29080
  };
@@ -1,9 +1,33 @@
1
+ import type { IAddress, IWSMonitorHeaders } from '../../types';
1
2
  import type { IOctavfiPortfolio } from './types';
2
3
  /**
3
- * Fetches portfolio data from Octavfi API.
4
- * Note: The API currently doesn't support multiple addresses in a single request,
5
- * so individual requests are made for each address.
6
- * @param addresses - Array of addresses to fetch data for.
7
- * @returns Array of portfolio data (may be empty if all requests fail).
4
+ * Response of the August API's vault-level Octav endpoint.
5
+ *
6
+ * Keys are the vault's Solana operator addresses (case-sensitive base58).
7
+ * Values are the operator's raw Octav portfolio, or an `{ error }` object when
8
+ * the backend holds no usable portfolio for that operator.
8
9
  */
9
- export declare function fetchOctavfiPortfolios(addresses: string[]): Promise<IOctavfiPortfolio[]>;
10
+ export type IVaultOctavResponse = Record<string, IOctavfiPortfolio | {
11
+ error: string;
12
+ }>;
13
+ /**
14
+ * Fetch the Octav portfolios of every Solana operator of a vault in a single
15
+ * request to the August public API.
16
+ *
17
+ * The API serves these from a cache that a backend cron refreshes, so this
18
+ * function never calls Octav and needs no Octav credentials. It makes exactly
19
+ * one HTTP request per call and never throws.
20
+ *
21
+ * @param vaultAddress - Vault address: EVM hex or Solana base58.
22
+ * @param headers - Optional monitoring headers forwarded with the request.
23
+ * @returns Dictionary of operator address to portfolio or error on a 200 or
24
+ * 207 (partial success) response; `false` on any other status or when the
25
+ * request fails.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const response = await fetchVaultOctavResponse(vaultAddress);
30
+ * const portfolio = response ? response[borrower] : undefined;
31
+ * ```
32
+ */
33
+ export declare function fetchVaultOctavResponse(vaultAddress: IAddress, headers?: IWSMonitorHeaders): Promise<IVaultOctavResponse | false>;
@@ -1,103 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchOctavfiPortfolios = fetchOctavfiPortfolios;
4
- const ethers_1 = require("ethers");
5
- const utils_1 = require("../../adapters/solana/utils");
3
+ exports.fetchVaultOctavResponse = fetchVaultOctavResponse;
6
4
  const core_1 = require("../../core");
7
- const BASE_URL = 'https://api.octav.fi';
8
- const OCTAVFI_API_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2hhc3VyYS5pby9qd3QvY2xhaW1zIjp7IngtaGFzdXJhLWRlZmF1bHQtcm9sZSI6InVzZXIiLCJ4LWhhc3VyYS1hbGxvd2VkLXJvbGVzIjpbInVzZXIiXSwieC1oYXN1cmEtdXNlci1pZCI6ImF1Z3VzdDEyMjM0In19.zaMUtrtdC82uaDh6XSZrsneEcKO3PFOE6FyX3G-MR6c';
9
5
  /**
10
- * Filters addresses to only include EVM and Solana wallet addresses.
11
- * Excludes Sui addresses and other non-supported address formats.
6
+ * Fetch the Octav portfolios of every Solana operator of a vault in a single
7
+ * request to the August public API.
12
8
  *
13
- * @param addresses - Array of addresses to filter
14
- * @returns Array containing only EVM and Solana addresses
15
- */
16
- function filterEvmAndSolanaAddresses(addresses) {
17
- return addresses.filter((address) => {
18
- if (!address || typeof address !== 'string')
19
- return false;
20
- if ((0, ethers_1.isAddress)(address)) {
21
- return true;
22
- }
23
- if (utils_1.SolanaUtils.isSolanaAddress(address)) {
24
- return true;
25
- }
26
- core_1.Logger.log.info('filterEvmAndSolanaAddresses.excluded', { address });
27
- return false;
28
- });
29
- }
30
- /**
31
- * Fetches portfolio data for a single address from Octavfi API.
32
- * @param address - Single address to fetch data for.
33
- * @returns Portfolio data or null if request fails.
9
+ * The API serves these from a cache that a backend cron refreshes, so this
10
+ * function never calls Octav and needs no Octav credentials. It makes exactly
11
+ * one HTTP request per call and never throws.
12
+ *
13
+ * @param vaultAddress - Vault address: EVM hex or Solana base58.
14
+ * @param headers - Optional monitoring headers forwarded with the request.
15
+ * @returns Dictionary of operator address to portfolio or error on a 200 or
16
+ * 207 (partial success) response; `false` on any other status or when the
17
+ * request fails.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const response = await fetchVaultOctavResponse(vaultAddress);
22
+ * const portfolio = response ? response[borrower] : undefined;
23
+ * ```
34
24
  */
35
- async function fetchSinglePortfolio(address) {
25
+ async function fetchVaultOctavResponse(vaultAddress, headers) {
36
26
  try {
37
- const response = await fetch(`${BASE_URL}/v1/portfolio?addresses=${address}`, {
38
- method: 'GET',
39
- headers: {
40
- 'Content-Type': 'application/json',
41
- Authorization: `Bearer ${OCTAVFI_API_KEY}`,
42
- },
43
- });
44
- if (!response.ok) {
45
- const errorText = await response.text();
46
- core_1.Logger.log.error('fetchSinglePortfolio', new Error(`HTTP ${response.status} ${response.statusText}: ${errorText}`), {
47
- address,
48
- status: response.status,
49
- statusText: response.statusText,
50
- });
51
- return null;
52
- }
53
- const data = await response.json();
54
- if (!data || typeof data !== 'object') {
55
- core_1.Logger.log.error('fetchSinglePortfolio.unexpected-type', new Error(`unexpected response type: ${typeof data}`), { address });
56
- return null;
27
+ const response = await (0, core_1.fetchAugustPublic)(core_1.WEBSERVER_ENDPOINTS.public.tokenizedVault.octav(vaultAddress), { headers: headers });
28
+ if (response.status === 200 || response.status === 207) {
29
+ return (await response.json());
57
30
  }
58
- if (data.error) {
59
- core_1.Logger.log.error('fetchSinglePortfolio.api-error', new Error(String(data.error)), { address });
60
- return null;
61
- }
62
- // Handle nested array response: [[portfolio]] or [portfolio] or portfolio
63
- let portfolio = data;
64
- if (Array.isArray(data)) {
65
- if (data.length > 0 && Array.isArray(data[0])) {
66
- // Nested array: [[portfolio]]
67
- portfolio = data[0][0];
68
- }
69
- else if (data.length > 0) {
70
- // Single array: [portfolio]
71
- portfolio = data[0];
72
- }
73
- else {
74
- return null;
75
- }
76
- }
77
- // Return raw Octavfi data (transformation should happen separately when needed)
78
- return portfolio;
79
- }
80
- catch (error) {
81
- core_1.Logger.log.error('fetchSinglePortfolio', error, { address });
82
- return null;
31
+ core_1.Logger.log.error('fetchVaultOctavResponse', new Error(`HTTP ${response.status} ${response.statusText}`), { status: response.status, statusText: response.statusText });
32
+ return false;
83
33
  }
84
- }
85
- /**
86
- * Fetches portfolio data from Octavfi API.
87
- * Note: The API currently doesn't support multiple addresses in a single request,
88
- * so individual requests are made for each address.
89
- * @param addresses - Array of addresses to fetch data for.
90
- * @returns Array of portfolio data (may be empty if all requests fail).
91
- */
92
- async function fetchOctavfiPortfolios(addresses) {
93
- const filteredAddresses = filterEvmAndSolanaAddresses(addresses);
94
- if (filteredAddresses.length === 0) {
95
- return [];
34
+ catch (e) {
35
+ core_1.Logger.log.error('fetchVaultOctavResponse', e);
36
+ return false;
96
37
  }
97
- // Fetch portfolios for each address in parallel
98
- const portfolioPromises = filteredAddresses.map((address) => fetchSinglePortfolio(address));
99
- const portfolios = await Promise.all(portfolioPromises);
100
- // Filter out null results (failed requests)
101
- return portfolios.filter((portfolio) => portfolio !== null);
102
38
  }
103
39
  //# sourceMappingURL=fetcher.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augustdigital/sdk",
3
- "version": "9.9.0",
3
+ "version": "9.9.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/sdk.d.ts",
6
6
  "keywords": [