@augustdigital/sdk 9.9.0 → 9.10.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.
- package/lib/adapters/solana/confirm.d.ts +88 -0
- package/lib/adapters/solana/confirm.js +291 -0
- package/lib/adapters/solana/index.d.ts +1 -1
- package/lib/adapters/solana/utils.d.ts +2 -1
- package/lib/adapters/solana/utils.js +3 -1
- package/lib/adapters/solana/vault.actions.d.ts +6 -0
- package/lib/adapters/solana/vault.actions.js +6 -0
- package/lib/adapters/stellar/soroban.js +3 -13
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/constants/core.d.ts +1 -0
- package/lib/core/constants/core.js +1 -0
- package/lib/core/errors/index.d.ts +29 -1
- package/lib/core/errors/index.js +36 -1
- package/lib/core/helpers/concurrency.d.ts +14 -0
- package/lib/core/helpers/concurrency.js +21 -0
- package/lib/modules/vaults/getters.d.ts +40 -17
- package/lib/modules/vaults/getters.js +48 -25
- package/lib/sdk.d.ts +119 -23
- package/lib/services/octavfi/fetcher.d.ts +30 -6
- package/lib/services/octavfi/fetcher.js +27 -91
- package/lib/types/sub-accounts.d.ts +13 -3
- package/package.json +1 -1
package/lib/sdk.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Abi } from 'abitype';
|
|
2
2
|
import type { AbiParametersToPrimitiveTypes } from 'abitype';
|
|
3
|
-
import
|
|
3
|
+
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
4
4
|
import type { BaseContract } from 'ethers';
|
|
5
5
|
import { Commitment } from '@solana/web3.js';
|
|
6
|
+
import { ConfirmOptions } from '@solana/web3.js';
|
|
6
7
|
import { Connection } from '@solana/web3.js';
|
|
7
8
|
import type { ContractTransaction } from 'ethers';
|
|
8
9
|
import type { ContractTransactionResponse } from 'ethers';
|
|
@@ -28,9 +29,12 @@ import type { Result } from 'ethers';
|
|
|
28
29
|
import type { SendTransactionOptions } from '@solana/wallet-adapter-base';
|
|
29
30
|
import type * as Sentry from '@sentry/browser';
|
|
30
31
|
import { Signer } from 'ethers';
|
|
32
|
+
import { Signer as Signer_2 } from '@solana/web3.js';
|
|
31
33
|
import { Transaction } from '@solana/web3.js';
|
|
32
34
|
import { TransactionReceipt } from 'ethers';
|
|
33
35
|
import { TransactionResponse } from 'ethers';
|
|
36
|
+
import { TransactionSignature } from '@solana/web3.js';
|
|
37
|
+
import { VersionedTransaction } from '@solana/web3.js';
|
|
34
38
|
import { Wallet } from 'ethers';
|
|
35
39
|
import type { WalletClient } from 'viem';
|
|
36
40
|
import { web3 } from '@coral-xyz/anchor';
|
|
@@ -15201,9 +15205,14 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
15201
15205
|
* position as pure profit — a plausible-looking but wrong number.
|
|
15202
15206
|
*
|
|
15203
15207
|
* This guard rejects exactly that state: a non-zero position with no recorded
|
|
15204
|
-
* deposits *and* no recorded withdrawals.
|
|
15205
|
-
*
|
|
15208
|
+
* deposits, no shares received by transfer *and* no recorded withdrawals. It
|
|
15209
|
+
* also rejects a non-zero position with no recorded deposits when a share mint
|
|
15210
|
+
* to the wallet has no matching deposit (`mintsMatchHistory: false`): the mint
|
|
15211
|
+
* proves a deposit the history failed to return, so neither a peer transfer
|
|
15212
|
+
* nor a withdrawal makes the cost basis complete. Otherwise, any of the
|
|
15213
|
+
* following is treated as consistent and passes:
|
|
15206
15214
|
* - deposits are present (the normal, computable case);
|
|
15215
|
+
* - shares were received by transfer and priced (see {@link transferCostBasis});
|
|
15207
15216
|
* - withdrawals are present (a fully-exited-then-re-entered position is still
|
|
15208
15217
|
* computable — the withdrawal records prove history loaded);
|
|
15209
15218
|
* - the current position is zero (the wallet never interacted or fully exited,
|
|
@@ -15213,15 +15222,17 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
15213
15222
|
* path with no added latency.
|
|
15214
15223
|
*
|
|
15215
15224
|
* Shares received by a direct token transfer (never deposited, never withdrew)
|
|
15216
|
-
* reach this guard as
|
|
15217
|
-
* with {@link transferCostBasis} first. The guard still throws for
|
|
15218
|
-
* wallet when its transfers cannot be read or priced
|
|
15225
|
+
* reach this guard as `receivedByTransferRaw`: {@link getVaultUserLifetimePnl}
|
|
15226
|
+
* prices them with {@link transferCostBasis} first. The guard still throws for
|
|
15227
|
+
* such a wallet when its transfers cannot be read or priced, or when a share
|
|
15228
|
+
* mint to it has no indexed deposit.
|
|
15219
15229
|
*
|
|
15220
15230
|
* @param params - See {@link PnlHistoryConsistencyParams}.
|
|
15221
15231
|
* @returns `void` when the history is consistent.
|
|
15222
15232
|
* @throws {@link AugustHistoryUnavailableError} with code `HISTORY_UNAVAILABLE`
|
|
15223
|
-
* and `context: { vault, wallet }` when a non-zero position has
|
|
15224
|
-
*
|
|
15233
|
+
* and `context: { vault, wallet }` when a non-zero position has no deposits
|
|
15234
|
+
* recorded and either a share mint without a matching deposit or neither
|
|
15235
|
+
* received shares nor withdrawals. The message carries the
|
|
15225
15236
|
* `#getVaultUserLifetimePnl::<vault>::<wallet>` prefix so it groups with the
|
|
15226
15237
|
* other errors leaving the getter.
|
|
15227
15238
|
* @example
|
|
@@ -15230,12 +15241,14 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
15230
15241
|
* vault,
|
|
15231
15242
|
* wallet,
|
|
15232
15243
|
* hasDeposits: depositsByAsset.size > 0,
|
|
15244
|
+
* mintsMatchHistory,
|
|
15245
|
+
* receivedByTransferRaw: costBasis.receivedByTransferRaw,
|
|
15233
15246
|
* totalWithdrawnRaw,
|
|
15234
15247
|
* currentPositionRaw: currentPositionValue.raw,
|
|
15235
15248
|
* });
|
|
15236
15249
|
* ```
|
|
15237
15250
|
*/
|
|
15238
|
-
export declare function assertPnlHistoryConsistent({ vault, wallet, hasDeposits, totalWithdrawnRaw, currentPositionRaw, }: PnlHistoryConsistencyParams): void;
|
|
15251
|
+
export declare function assertPnlHistoryConsistent({ vault, wallet, hasDeposits, mintsMatchHistory, receivedByTransferRaw, totalWithdrawnRaw, currentPositionRaw, }: PnlHistoryConsistencyParams): void;
|
|
15239
15252
|
|
|
15240
15253
|
/**
|
|
15241
15254
|
* Guard against converting lifetime PnL to USD with a fabricated price.
|
|
@@ -15922,7 +15935,7 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
15922
15935
|
* ```
|
|
15923
15936
|
*/
|
|
15924
15937
|
/** Stable error codes attached to SDK errors. */
|
|
15925
|
-
export declare type AugustErrorCode = 'AUTH_MISSING_KEY' | 'AUTH_INVALID_KEY' | 'AUTH_FORBIDDEN' | 'AUTH_UNAUTHORIZED' | 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS' | 'ACCOUNT_NOT_FUNDED' | 'NETWORK_ERROR' | 'TIMEOUT' | 'RATE_LIMITED' | 'SERVER_ERROR' | 'HISTORY_UNAVAILABLE' | 'PRICE_UNAVAILABLE' | 'UNKNOWN';
|
|
15938
|
+
export declare type AugustErrorCode = 'AUTH_MISSING_KEY' | 'AUTH_INVALID_KEY' | 'AUTH_FORBIDDEN' | 'AUTH_UNAUTHORIZED' | 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS' | 'ACCOUNT_NOT_FUNDED' | 'NETWORK_ERROR' | 'TIMEOUT' | 'RATE_LIMITED' | 'SERVER_ERROR' | 'TRANSACTION_UNCONFIRMED' | 'HISTORY_UNAVAILABLE' | 'PRICE_UNAVAILABLE' | 'UNKNOWN';
|
|
15926
15939
|
|
|
15927
15940
|
/** Options accepted by every SDK error constructor. */
|
|
15928
15941
|
export declare interface AugustErrorOptions {
|
|
@@ -16863,6 +16876,35 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
16863
16876
|
toJSON(): Record<string, unknown>;
|
|
16864
16877
|
}
|
|
16865
16878
|
|
|
16879
|
+
/**
|
|
16880
|
+
* A transaction was sent but its outcome could not be established
|
|
16881
|
+
* (`TRANSACTION_UNCONFIRMED`). It may have landed: check {@link signature}
|
|
16882
|
+
* before resubmitting, or a deposit or redeem can execute twice.
|
|
16883
|
+
* `context.reason` says what was seen (e.g. `expired_not_found`: the blockhash
|
|
16884
|
+
* expired and no lookup found it, so it very likely never landed).
|
|
16885
|
+
*
|
|
16886
|
+
* @example
|
|
16887
|
+
* ```ts
|
|
16888
|
+
* try {
|
|
16889
|
+
* await sdk.solana.vaultDeposit(programId, idl, wallet, amount, undefined, vault);
|
|
16890
|
+
* } catch (err) {
|
|
16891
|
+
* if (err instanceof AugustTransactionError) showPending(err.signature);
|
|
16892
|
+
* else throw err;
|
|
16893
|
+
* }
|
|
16894
|
+
* ```
|
|
16895
|
+
*/
|
|
16896
|
+
export declare class AugustTransactionError extends AugustSDKError {
|
|
16897
|
+
/** Signature of the transaction that was sent. */
|
|
16898
|
+
readonly signature: string;
|
|
16899
|
+
/**
|
|
16900
|
+
* @param message - Human-readable description, naming the signature.
|
|
16901
|
+
* @param signature - Signature of the transaction that was sent.
|
|
16902
|
+
* @param options - Standard SDK error options.
|
|
16903
|
+
*/
|
|
16904
|
+
constructor(message: string, signature: string, options?: AugustErrorOptions);
|
|
16905
|
+
toJSON(): Record<string, unknown>;
|
|
16906
|
+
}
|
|
16907
|
+
|
|
16866
16908
|
/** Caller-side input failed validation. */
|
|
16867
16909
|
export declare class AugustValidationError extends AugustSDKError {
|
|
16868
16910
|
constructor(code: Extract<AugustErrorCode, 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS' | 'ACCOUNT_NOT_FUNDED'>, message: string, options?: AugustErrorOptions);
|
|
@@ -17478,6 +17520,29 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
17478
17520
|
*/
|
|
17479
17521
|
export declare function balanceOf(signer: IContractRunner, options: IBalanceOfOptions): Promise<bigint>;
|
|
17480
17522
|
|
|
17523
|
+
/**
|
|
17524
|
+
* `AnchorProvider` whose `sendAndConfirm` — what `program.methods…rpc()` calls —
|
|
17525
|
+
* confirms with {@link confirmByBlockhash} instead of Anchor's signature-only
|
|
17526
|
+
* WebSocket wait. Signing and Anchor's error translation are unchanged.
|
|
17527
|
+
*/
|
|
17528
|
+
declare class BlockhashConfirmingProvider extends AnchorProvider {
|
|
17529
|
+
/**
|
|
17530
|
+
* Sign, send and confirm a transaction.
|
|
17531
|
+
*
|
|
17532
|
+
* @param tx - Transaction to send. Its blockhash (and fee payer, if unset)
|
|
17533
|
+
* are set here. A `VersionedTransaction` already carries a blockhash this
|
|
17534
|
+
* cannot learn the expiry of, so it takes Anchor's default path.
|
|
17535
|
+
* @param signers - Extra signers besides the wallet.
|
|
17536
|
+
* @param opts - Defaults to the provider's options.
|
|
17537
|
+
* @returns The transaction signature.
|
|
17538
|
+
* @throws See {@link confirmByBlockhash}; also whatever the wallet or
|
|
17539
|
+
* `sendRawTransaction` throws (user rejection, preflight failure).
|
|
17540
|
+
* @remarks **RPC cost.** `getLatestBlockhash` + `sendRawTransaction`, then
|
|
17541
|
+
* the confirmation polls described on {@link confirmByBlockhash}.
|
|
17542
|
+
*/
|
|
17543
|
+
sendAndConfirm(tx: Transaction | VersionedTransaction, signers?: Signer_2[], opts?: ConfirmOptions): Promise<TransactionSignature>;
|
|
17544
|
+
}
|
|
17545
|
+
|
|
17481
17546
|
/**
|
|
17482
17547
|
* Build an ERC-8021 schema-0 attribution suffix from builder codes.
|
|
17483
17548
|
*
|
|
@@ -20179,16 +20244,18 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
20179
20244
|
* shares add to `totalDeposited` (and are reported again as
|
|
20180
20245
|
* `receivedByTransfer`), sent shares add to `totalWithdrawn`. This holds
|
|
20181
20246
|
* alongside indexed deposits, so a wallet that received shares and also
|
|
20182
|
-
* deposited is not credited with the received shares as profit. LayerZero
|
|
20183
|
-
* OVaults
|
|
20184
|
-
* composer delivers cross-chain deposits by transfer
|
|
20247
|
+
* deposited is not credited with the received shares as profit. On LayerZero
|
|
20248
|
+
* OVaults, transfers from or to the hub composer and share OFT do not count,
|
|
20249
|
+
* because the composer delivers cross-chain deposits by transfer and those
|
|
20250
|
+
* are already counted as LayerZero deposits.
|
|
20185
20251
|
*
|
|
20186
20252
|
* Gaps in the indexed history: a share mint with no `Deposit` event counts as
|
|
20187
20253
|
* a deposit of the assets in its `ReserveDeposit` event
|
|
20188
20254
|
* ({@link selectReserveDeposits}; High Growth ETH emits it for Kelp gain-adapter
|
|
20189
20255
|
* deposits), and a withdrawal request the vault logged twice counts once
|
|
20190
20256
|
* ({@link countWithdrawalRequestsOnce}). Transfers fold in for a depositor only
|
|
20191
|
-
* once every mint is explained.
|
|
20257
|
+
* once every mint is explained. A wallet with no indexed deposit and a mint
|
|
20258
|
+
* that no deposit explains throws `HISTORY_UNAVAILABLE`.
|
|
20192
20259
|
*
|
|
20193
20260
|
* Tokenized Vault V2 redemptions carry only shares, so a settled one counts at
|
|
20194
20261
|
* the assets the vault paid, or at the share ratio on its claim date when the
|
|
@@ -20203,9 +20270,8 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
20203
20270
|
* for a Tokenized Vault V2 wallet with redemption requests, a `lagDuration()`
|
|
20204
20271
|
* read plus one backend timeseries request. A timeseries window with no usable
|
|
20205
20272
|
* ratio (a closed vault whose history stopped earlier) is read again in full,
|
|
20206
|
-
* so the latest earlier day still prices it.
|
|
20207
|
-
*
|
|
20208
|
-
* read; for LayerZero vaults it runs only when history holds no deposit.
|
|
20273
|
+
* so the latest earlier day still prices it. The transfer query runs for
|
|
20274
|
+
* every vault, in parallel with the history read.
|
|
20209
20275
|
*
|
|
20210
20276
|
* @param vault - Vault contract address
|
|
20211
20277
|
* @param wallet - User wallet address
|
|
@@ -20213,7 +20279,8 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
20213
20279
|
* @returns Lifetime PnL data in both native token and USD
|
|
20214
20280
|
* @throws {@link AugustHistoryUnavailableError} (`HISTORY_UNAVAILABLE`) when a
|
|
20215
20281
|
* live position has no indexed deposits, withdrawals or priceable share
|
|
20216
|
-
* transfers
|
|
20282
|
+
* transfers, or has no indexed deposit while a share mint to the wallet has
|
|
20283
|
+
* no matching deposit.
|
|
20217
20284
|
* @throws {@link AugustPriceUnavailableError} (`PRICE_UNAVAILABLE`) when the
|
|
20218
20285
|
* underlying asset has no USD price, or `asset()` cannot be read.
|
|
20219
20286
|
*/
|
|
@@ -20389,6 +20456,9 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
20389
20456
|
* or when the wallet's deposit-mint balance is below `depositAmount`.
|
|
20390
20457
|
* @throws AugustSDKError when a candidate token account's balance cannot be
|
|
20391
20458
|
* read, or wrapping any downstream failure (`cause` preserved).
|
|
20459
|
+
* @throws AugustTransactionError (`TRANSACTION_UNCONFIRMED`) when the
|
|
20460
|
+
* transaction was sent but its outcome could not be established; check
|
|
20461
|
+
* `signature` before resubmitting.
|
|
20392
20462
|
* @remarks **Side effects.** Submits exactly one transaction, signed by the
|
|
20393
20463
|
* provider's wallet. When the wallet has no share account, that transaction
|
|
20394
20464
|
* also creates one, and `publicKey` pays its rent — roughly 0.00204 SOL,
|
|
@@ -20437,6 +20507,9 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
20437
20507
|
* or when the wallet holds fewer shares than `redeemShares`.
|
|
20438
20508
|
* @throws AugustSDKError when a candidate token account's balance cannot be
|
|
20439
20509
|
* read, or wrapping any downstream failure (`cause` preserved).
|
|
20510
|
+
* @throws AugustTransactionError (`TRANSACTION_UNCONFIRMED`) when the
|
|
20511
|
+
* transaction was sent but its outcome could not be established; check
|
|
20512
|
+
* `signature` before resubmitting.
|
|
20440
20513
|
* @remarks **Side effects.** Submits exactly one transaction, signed by the
|
|
20441
20514
|
* provider's wallet. That transaction also creates the payout account when
|
|
20442
20515
|
* the wallet has none, and the vault's fee-recipient account when *it* has
|
|
@@ -24884,9 +24957,10 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
24884
24957
|
}
|
|
24885
24958
|
|
|
24886
24959
|
/**
|
|
24887
|
-
* One subaccount record
|
|
24888
|
-
*
|
|
24889
|
-
*
|
|
24960
|
+
* One subaccount record (backend `ISubaccountRead` schema), as returned by the
|
|
24961
|
+
* admin-only `GET /subaccount` directory, `GET /users/{address}/subaccounts`
|
|
24962
|
+
* and `GET /org/subaccounts`. Nullable fields are optional metadata the
|
|
24963
|
+
* operations team may not have filled in.
|
|
24890
24964
|
*/
|
|
24891
24965
|
export declare interface IWSSubaccountListItem {
|
|
24892
24966
|
id: string;
|
|
@@ -24908,6 +24982,15 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
24908
24982
|
variant: string | null;
|
|
24909
24983
|
default_fee_rate_in_bips: number | null;
|
|
24910
24984
|
wallet_role: string | null;
|
|
24985
|
+
/**
|
|
24986
|
+
* Cached USD account value, refreshed out of band by an hourly backend job.
|
|
24987
|
+
* A sort key and placeholder, not an authoritative NAV — read the live value
|
|
24988
|
+
* from the subaccount summary. `null` before the job's first run; absent on
|
|
24989
|
+
* backends that predate the field.
|
|
24990
|
+
*/
|
|
24991
|
+
latest_account_value?: number | null;
|
|
24992
|
+
/** Naive-UTC ISO timestamp of `latest_account_value`. */
|
|
24993
|
+
account_value_updated_at?: string | null;
|
|
24911
24994
|
chains: IWSSubaccountListChain[];
|
|
24912
24995
|
}
|
|
24913
24996
|
|
|
@@ -25524,7 +25607,9 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
25524
25607
|
*
|
|
25525
25608
|
* A depositor whose history misses a mint ({@link historyCoversMints}) is the
|
|
25526
25609
|
* exception: its transfers do not count, so the result matches what the getter
|
|
25527
|
-
* returned before transfers counted for depositors.
|
|
25610
|
+
* returned before transfers counted for depositors. A wallet with no deposit
|
|
25611
|
+
* still gets a basis here when its history misses a mint, but
|
|
25612
|
+
* {@link assertPnlHistoryConsistent} rejects it. On a LayerZero OVault the
|
|
25528
25613
|
* caller leaves the hub composer and share OFT out of the transfers (see
|
|
25529
25614
|
* {@link selectPeerTransfers}): the composer's deliveries are already counted
|
|
25530
25615
|
* as LayerZero deposits, and shares bridged to a spoke chain still count in the
|
|
@@ -25587,6 +25672,16 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
25587
25672
|
* (subgraph deposits or LayerZero cross-chain deposits).
|
|
25588
25673
|
*/
|
|
25589
25674
|
hasDeposits: boolean;
|
|
25675
|
+
/**
|
|
25676
|
+
* Whether the indexed deposits explain every share mint to the wallet (see
|
|
25677
|
+
* {@link historyCoversMints}). Defaults to `true`.
|
|
25678
|
+
*/
|
|
25679
|
+
mintsMatchHistory?: boolean;
|
|
25680
|
+
/**
|
|
25681
|
+
* Shares received by peer transfer, priced in raw base units (asset
|
|
25682
|
+
* decimals) by {@link transferCostBasis}. Defaults to zero.
|
|
25683
|
+
*/
|
|
25684
|
+
receivedByTransferRaw?: bigint;
|
|
25590
25685
|
/** Total withdrawn, in raw base units (asset decimals). */
|
|
25591
25686
|
totalWithdrawnRaw: bigint;
|
|
25592
25687
|
/** Current on-chain position value, in raw base units (asset decimals). */
|
|
@@ -27174,7 +27269,7 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
27174
27269
|
getProvider: ({ connection, publicKey, signTransaction, }: {
|
|
27175
27270
|
publicKey: PublicKey;
|
|
27176
27271
|
signTransaction: (<T extends Transaction | web3.VersionedTransaction>(transaction: T) => Promise<T>) | undefined;
|
|
27177
|
-
} & ISolanaConnectionOptions) =>
|
|
27272
|
+
} & ISolanaConnectionOptions) => BlockhashConfirmingProvider;
|
|
27178
27273
|
getReadOnlyProvider: ({ connection }: ISolanaConnectionOptions) => AnchorProvider;
|
|
27179
27274
|
deriveShareMintPda: (vaultProgramId: PublicKey | string) => web3.PublicKey;
|
|
27180
27275
|
deriveVaultStatePda: (vaultProgramId: PublicKey | string) => web3.PublicKey;
|
|
@@ -29074,6 +29169,7 @@ declare type AsArray<T> = T extends readonly unknown[] ? T : never;
|
|
|
29074
29169
|
summary: (vaultAddress: IAddress) => string;
|
|
29075
29170
|
withdrawals: (chain: string, vaultAddress: IAddress) => string;
|
|
29076
29171
|
debank: (vaultAddress: IAddress) => string;
|
|
29172
|
+
octav: (vaultAddress: IAddress) => string;
|
|
29077
29173
|
userHistory: (vaultAddress: IAddress, wallet: IAddress) => string;
|
|
29078
29174
|
archivedVaults: string;
|
|
29079
29175
|
};
|
|
@@ -1,9 +1,33 @@
|
|
|
1
|
+
import type { IAddress, IWSMonitorHeaders } from '../../types';
|
|
1
2
|
import type { IOctavfiPortfolio } from './types';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
|
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.
|
|
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
|
-
*
|
|
11
|
-
*
|
|
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
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
|
25
|
+
async function fetchVaultOctavResponse(vaultAddress, headers) {
|
|
36
26
|
try {
|
|
37
|
-
const response = await
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
|
@@ -9,9 +9,10 @@ export interface IWSSubaccountListChain {
|
|
|
9
9
|
name: string;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* One subaccount record
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* One subaccount record (backend `ISubaccountRead` schema), as returned by the
|
|
13
|
+
* admin-only `GET /subaccount` directory, `GET /users/{address}/subaccounts`
|
|
14
|
+
* and `GET /org/subaccounts`. Nullable fields are optional metadata the
|
|
15
|
+
* operations team may not have filled in.
|
|
15
16
|
*/
|
|
16
17
|
export interface IWSSubaccountListItem {
|
|
17
18
|
id: string;
|
|
@@ -33,6 +34,15 @@ export interface IWSSubaccountListItem {
|
|
|
33
34
|
variant: string | null;
|
|
34
35
|
default_fee_rate_in_bips: number | null;
|
|
35
36
|
wallet_role: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Cached USD account value, refreshed out of band by an hourly backend job.
|
|
39
|
+
* A sort key and placeholder, not an authoritative NAV — read the live value
|
|
40
|
+
* from the subaccount summary. `null` before the job's first run; absent on
|
|
41
|
+
* backends that predate the field.
|
|
42
|
+
*/
|
|
43
|
+
latest_account_value?: number | null;
|
|
44
|
+
/** Naive-UTC ISO timestamp of `latest_account_value`. */
|
|
45
|
+
account_value_updated_at?: string | null;
|
|
36
46
|
chains: IWSSubaccountListChain[];
|
|
37
47
|
}
|
|
38
48
|
export interface IWSSubAccountHealthFactor {
|