@augustdigital/sdk 8.3.2 → 8.6.0
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 +207 -117
- package/lib/abis/ERC20_Bytes32.d.ts +4 -0
- package/lib/abis/ERC20_Bytes32.js +4 -0
- package/lib/abis/ERC4626.d.ts +1 -0
- package/lib/abis/ERC4626.js +1 -0
- package/lib/abis/ERC721.d.ts +1 -0
- package/lib/abis/ERC721.js +1 -0
- package/lib/abis/FeeOracle.js +1 -0
- package/lib/abis/LendingPool.js +1 -0
- package/lib/abis/LendingPoolV2.js +1 -0
- package/lib/abis/Multicall3.js +3 -0
- package/lib/abis/OFT.d.ts +20 -0
- package/lib/abis/OFT.js +20 -0
- package/lib/abis/SmartAccount.d.ts +1 -0
- package/lib/abis/SmartAccount.js +3 -0
- package/lib/abis/SwapRouter.d.ts +1 -0
- package/lib/abis/SwapRouter.js +1 -0
- package/lib/abis/UniversalSignatureValidator.js +3 -0
- package/lib/abis/index.d.ts +5 -0
- package/lib/abis/index.js +5 -0
- package/lib/adapters/evm/getters.d.ts +17 -2
- package/lib/adapters/evm/getters.js +35 -3
- package/lib/adapters/evm/index.d.ts +266 -4
- package/lib/adapters/evm/index.js +270 -1
- package/lib/adapters/evm/utils.d.ts +6 -0
- package/lib/adapters/evm/utils.js +7 -0
- package/lib/adapters/solana/constants.d.ts +1 -1
- package/lib/adapters/solana/constants.js +4 -1
- package/lib/adapters/solana/getters.d.ts +9 -1
- package/lib/adapters/solana/getters.js +21 -0
- package/lib/adapters/solana/idl/vault-idl.js +9 -0
- package/lib/adapters/solana/index.d.ts +59 -4
- package/lib/adapters/solana/index.js +61 -0
- package/lib/adapters/solana/types.d.ts +1 -1
- package/lib/adapters/solana/utils.d.ts +31 -3
- package/lib/adapters/solana/utils.js +79 -4
- package/lib/adapters/solana/vault.actions.d.ts +23 -4
- package/lib/adapters/solana/vault.actions.js +47 -3
- package/lib/adapters/stellar/actions.d.ts +26 -1
- package/lib/adapters/stellar/actions.js +33 -0
- package/lib/adapters/stellar/constants.d.ts +26 -0
- package/lib/adapters/stellar/constants.js +29 -0
- package/lib/adapters/stellar/getters.d.ts +56 -0
- package/lib/adapters/stellar/getters.js +81 -0
- package/lib/adapters/stellar/index.d.ts +70 -0
- package/lib/adapters/stellar/index.js +71 -0
- package/lib/adapters/stellar/soroban.d.ts +21 -1
- package/lib/adapters/stellar/soroban.js +47 -1
- package/lib/adapters/stellar/submit.d.ts +29 -0
- package/lib/adapters/stellar/submit.js +90 -5
- package/lib/adapters/stellar/types.d.ts +27 -0
- package/lib/adapters/stellar/types.js +3 -0
- package/lib/adapters/stellar/utils.d.ts +10 -0
- package/lib/adapters/stellar/utils.js +10 -0
- package/lib/adapters/sui/getters.d.ts +7 -1
- package/lib/adapters/sui/getters.js +6 -0
- package/lib/adapters/sui/index.d.ts +16 -1
- package/lib/adapters/sui/index.js +17 -0
- package/lib/adapters/sui/transformer.d.ts +8 -2
- package/lib/adapters/sui/transformer.js +7 -0
- package/lib/adapters/sui/types.d.ts +1 -1
- package/lib/adapters/sui/utils.d.ts +6 -0
- package/lib/adapters/sui/utils.js +6 -0
- package/lib/core/analytics/chain-name.d.ts +8 -0
- package/lib/core/analytics/chain-name.js +8 -0
- package/lib/core/analytics/constants.d.ts +4 -0
- package/lib/core/analytics/constants.js +4 -0
- package/lib/core/analytics/env.d.ts +25 -0
- package/lib/core/analytics/env.js +26 -0
- package/lib/core/analytics/index.d.ts +26 -0
- package/lib/core/analytics/index.js +35 -0
- package/lib/core/analytics/instrumentation.d.ts +26 -0
- package/lib/core/analytics/instrumentation.js +66 -2
- package/lib/core/analytics/method-taxonomy.d.ts +16 -0
- package/lib/core/analytics/method-taxonomy.js +18 -0
- package/lib/core/analytics/metrics.d.ts +23 -0
- package/lib/core/analytics/metrics.js +40 -0
- package/lib/core/analytics/sanitize.d.ts +38 -0
- package/lib/core/analytics/sanitize.js +46 -0
- package/lib/core/analytics/sentry-runtime.d.ts +11 -0
- package/lib/core/analytics/sentry-runtime.js +20 -1
- package/lib/core/analytics/sentry.d.ts +47 -2
- package/lib/core/analytics/sentry.js +115 -2
- package/lib/core/analytics/types.d.ts +28 -1
- package/lib/core/analytics/user-identity.d.ts +36 -2
- package/lib/core/analytics/user-identity.js +43 -1
- package/lib/core/analytics/version.d.ts +6 -1
- package/lib/core/analytics/version.js +6 -1
- package/lib/core/auth/verify.js +5 -0
- package/lib/core/base.class.d.ts +78 -3
- package/lib/core/base.class.js +66 -4
- package/lib/core/cache.d.ts +5 -0
- package/lib/core/cache.js +6 -0
- package/lib/core/constants/adapters.d.ts +16 -1
- package/lib/core/constants/adapters.js +28 -8
- package/lib/core/constants/core.d.ts +14 -1
- package/lib/core/constants/core.js +18 -0
- package/lib/core/constants/swap-router.d.ts +83 -1
- package/lib/core/constants/swap-router.js +91 -1
- package/lib/core/constants/vaults.d.ts +57 -1
- package/lib/core/constants/vaults.js +66 -1
- package/lib/core/constants/web3.d.ts +4 -1
- package/lib/core/constants/web3.js +15 -5
- package/lib/core/errors/index.d.ts +38 -2
- package/lib/core/errors/index.js +38 -0
- package/lib/core/fetcher.d.ts +136 -2
- package/lib/core/fetcher.js +229 -25
- package/lib/core/helpers/adapters.d.ts +10 -1
- package/lib/core/helpers/adapters.js +11 -0
- package/lib/core/helpers/chain-address.d.ts +10 -0
- package/lib/core/helpers/chain-address.js +11 -0
- package/lib/core/helpers/core.d.ts +49 -4
- package/lib/core/helpers/core.js +74 -7
- package/lib/core/helpers/explorer-link.d.ts +15 -1
- package/lib/core/helpers/explorer-link.js +14 -0
- package/lib/core/helpers/signer.d.ts +27 -1
- package/lib/core/helpers/signer.js +39 -0
- package/lib/core/helpers/swap-router.d.ts +33 -1
- package/lib/core/helpers/swap-router.js +32 -0
- package/lib/core/helpers/vault-version.d.ts +2 -1
- package/lib/core/helpers/vault-version.js +2 -0
- package/lib/core/helpers/vaults.d.ts +9 -1
- package/lib/core/helpers/vaults.js +22 -8
- package/lib/core/helpers/web3.d.ts +154 -2
- package/lib/core/helpers/web3.js +192 -15
- package/lib/core/logger/index.d.ts +55 -0
- package/lib/core/logger/index.js +19 -0
- package/lib/core/logger/slack.d.ts +3 -0
- package/lib/core/logger/slack.js +3 -0
- package/lib/core/vault-metadata.d.ts +7 -1
- package/lib/core/vault-metadata.js +6 -0
- package/lib/core/version-check.d.ts +52 -0
- package/lib/core/version-check.js +82 -1
- package/lib/evm/methods/crossChainVault.d.ts +90 -0
- package/lib/evm/methods/crossChainVault.js +187 -2
- package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
- package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
- package/lib/evm/methods/index.d.ts +1 -0
- package/lib/evm/methods/index.js +1 -0
- package/lib/evm/types/crossChain.d.ts +202 -0
- package/lib/evm/types/crossChain.js +12 -1
- package/lib/index.d.ts +16 -0
- package/lib/index.js +19 -0
- package/lib/main.d.ts +289 -6
- package/lib/main.js +312 -0
- package/lib/modules/api/index.d.ts +1 -0
- package/lib/modules/api/index.js +6 -0
- package/lib/modules/api/main.d.ts +52 -0
- package/lib/modules/api/main.js +130 -0
- package/lib/modules/sub-accounts/fetcher.d.ts +17 -2
- package/lib/modules/sub-accounts/fetcher.js +15 -0
- package/lib/modules/sub-accounts/main.d.ts +35 -2
- package/lib/modules/sub-accounts/main.js +39 -1
- package/lib/modules/sub-accounts/utils.d.ts +4 -1
- package/lib/modules/sub-accounts/utils.js +3 -0
- package/lib/modules/vaults/adapter.helpers.d.ts +21 -3
- package/lib/modules/vaults/adapter.helpers.js +34 -0
- package/lib/modules/vaults/fetcher.d.ts +45 -0
- package/lib/modules/vaults/fetcher.js +91 -4
- package/lib/modules/vaults/getters.d.ts +295 -0
- package/lib/modules/vaults/getters.js +567 -26
- package/lib/modules/vaults/index.d.ts +12 -0
- package/lib/modules/vaults/index.js +12 -0
- package/lib/modules/vaults/main.d.ts +292 -4
- package/lib/modules/vaults/main.js +382 -8
- package/lib/modules/vaults/read.actions.d.ts +170 -2
- package/lib/modules/vaults/read.actions.js +143 -0
- package/lib/modules/vaults/types.d.ts +34 -0
- package/lib/modules/vaults/utils/call-data-decoder.d.ts +48 -1
- package/lib/modules/vaults/utils/call-data-decoder.js +56 -0
- package/lib/modules/vaults/utils/date-utils.d.ts +39 -0
- package/lib/modules/vaults/utils/date-utils.js +47 -1
- package/lib/modules/vaults/utils.d.ts +85 -0
- package/lib/modules/vaults/utils.js +139 -7
- package/lib/modules/vaults/write.actions.d.ts +363 -3
- package/lib/modules/vaults/write.actions.js +399 -3
- package/lib/polyfills.js +4 -2
- package/lib/sdk.d.ts +23847 -0
- package/lib/services/coingecko/fetcher.d.ts +15 -1
- package/lib/services/coingecko/fetcher.js +30 -9
- package/lib/services/debank/fetcher.d.ts +15 -1
- package/lib/services/debank/fetcher.js +12 -0
- package/lib/services/debank/utils.d.ts +1 -1
- package/lib/services/debank/utils.js +18 -1
- package/lib/services/layerzero/deposits.d.ts +12 -1
- package/lib/services/layerzero/deposits.js +34 -11
- package/lib/services/layerzero/redeems.d.ts +11 -1
- package/lib/services/layerzero/redeems.js +13 -0
- package/lib/services/layerzero/utils.d.ts +8 -0
- package/lib/services/layerzero/utils.js +11 -0
- package/lib/services/octavfi/fetcher.d.ts +8 -1
- package/lib/services/octavfi/fetcher.js +25 -0
- package/lib/services/octavfi/types.d.ts +1 -1
- package/lib/services/octavfi/utils.d.ts +14 -2
- package/lib/services/octavfi/utils.js +44 -10
- package/lib/services/subgraph/fetcher.js +4 -2
- package/lib/services/subgraph/vaults.d.ts +12 -0
- package/lib/services/subgraph/vaults.js +119 -2
- package/lib/services/swap-quotes/index.d.ts +80 -0
- package/lib/services/swap-quotes/index.js +27 -1
- package/lib/services/swap-quotes/paraswap.d.ts +25 -0
- package/lib/services/swap-quotes/paraswap.js +22 -0
- package/lib/types/pools.d.ts +5 -2
- package/lib/types/staking.d.ts +1 -1
- package/lib/types/sub-accounts.d.ts +1 -1
- package/lib/types/subgraph.d.ts +10 -1
- package/lib/types/typed-contract.d.ts +64 -0
- package/lib/types/vaults.d.ts +163 -2
- package/lib/types/vaults.js +10 -0
- package/lib/types/web3.d.ts +9 -1
- package/lib/types/web3.js +1 -0
- package/lib/types/webserver.d.ts +47 -2
- package/package.json +6 -5
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The August Vaults Module.
|
|
4
|
+
*
|
|
5
|
+
* @module AugustVaults
|
|
6
|
+
*/
|
|
2
7
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
8
|
if (k2 === undefined) k2 = k;
|
|
4
9
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -40,7 +45,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
45
|
};
|
|
41
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
47
|
exports.AugustVaults = void 0;
|
|
48
|
+
/**
|
|
49
|
+
* Export getters
|
|
50
|
+
*/
|
|
43
51
|
__exportStar(require("./getters"), exports);
|
|
52
|
+
/**
|
|
53
|
+
* AugustVaults class
|
|
54
|
+
*/
|
|
44
55
|
const fetcher_1 = require("./fetcher");
|
|
45
56
|
const ethers_1 = require("ethers");
|
|
46
57
|
const getters_1 = require("./getters");
|
|
@@ -55,10 +66,16 @@ const constants_1 = require("../../adapters/sui/constants");
|
|
|
55
66
|
const vaults_2 = require("../../core/constants/vaults");
|
|
56
67
|
const write_actions_1 = require("./write.actions");
|
|
57
68
|
const read_actions_1 = require("./read.actions");
|
|
69
|
+
/**
|
|
70
|
+
* Vault operations class handling multi-chain vault queries and user positions.
|
|
71
|
+
* Supports both EVM and Solana vaults with unified interface.
|
|
72
|
+
*/
|
|
58
73
|
class AugustVaults extends core_1.AugustBase {
|
|
74
|
+
solanaService;
|
|
75
|
+
suiService;
|
|
76
|
+
headers = null;
|
|
59
77
|
constructor(baseConfig, solana, sui) {
|
|
60
78
|
super(baseConfig);
|
|
61
|
-
this.headers = null;
|
|
62
79
|
this.solanaService = solana;
|
|
63
80
|
this.suiService = sui || new sui_1.default();
|
|
64
81
|
this.headers = {
|
|
@@ -66,20 +83,51 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
66
83
|
'x-user-id': this.monitoring?.['x-user-id'],
|
|
67
84
|
};
|
|
68
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* @description deposit underlying token into the specified pool with adapter support. This is for when we cannot pass in a signer in sdk and need to do so as an arg
|
|
88
|
+
* @param signer signer / wallet object
|
|
89
|
+
* @param options object including pool contract address, user wallet address, string amount, and optional depositAsset
|
|
90
|
+
* @returns deposit tx hash
|
|
91
|
+
*/
|
|
69
92
|
async vaultDeposit(signer, options) {
|
|
70
93
|
return (0, write_actions_1.vaultDeposit)(signer, options);
|
|
71
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* @description deposit native token (ETH/AVAX/etc) into a vault using MultiAssetNativeDepositWrapper
|
|
97
|
+
* @param signer signer / wallet object
|
|
98
|
+
* @param options object including wrapper contract address, receiver address (optional), and amount
|
|
99
|
+
* @returns deposit tx hash
|
|
100
|
+
*/
|
|
72
101
|
async depositNative(signer, options) {
|
|
73
102
|
return (0, write_actions_1.depositNative)(signer, options);
|
|
74
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Fetch all vaults across configured networks with optional enrichment.
|
|
106
|
+
* Automatically filters by available providers and optionally by chain IDs.
|
|
107
|
+
* Includes closed vaults that are still visible (`status: 'closed'`,
|
|
108
|
+
* `is_visible: true`) so consumers can render positions held in closed
|
|
109
|
+
* vaults; closed vaults with `is_visible: false` are excluded.
|
|
110
|
+
* @param options Filtering and enrichment configuration
|
|
111
|
+
* @returns Array of vault objects with optional loans/allocations/positions
|
|
112
|
+
*/
|
|
75
113
|
async getVaults(options) {
|
|
114
|
+
// if (!(this.authorized && this.augustKey)) // @todo: commented out for integrators
|
|
76
115
|
const allVaults = await (0, core_1.fetchTokenizedVaults)(undefined, this.headers, options?.loadSubaccounts, options?.loadSnapshots);
|
|
77
|
-
const vaultsPerAvailableProviders = allVaults.filter((v) =>
|
|
116
|
+
const vaultsPerAvailableProviders = allVaults.filter((v) =>
|
|
117
|
+
// Stellar vaults are backend-only (no RPC provider required)
|
|
118
|
+
v?.chain_type === 'stellar' ||
|
|
119
|
+
// Solana vaults use this.solanaService (not this.providers). Without
|
|
120
|
+
// an explicit pass-through here they get silently dropped on any
|
|
121
|
+
// instance whose ACTIVE_RPC_URLS() doesn't register chainId -1.
|
|
122
|
+
// Gate on solanaService presence so we don't let a vault through that
|
|
123
|
+
// we have no adapter to fetch — that would crash the inner getter and
|
|
124
|
+
// turn into a PENDING entry that the final filter drops anyway.
|
|
78
125
|
(v?.chain_type === 'solana' && !!this.solanaService) ||
|
|
79
126
|
(this.providers?.[v?.chain] ? true : false));
|
|
80
127
|
const vaultsPerChainId = options?.chainIds
|
|
81
128
|
? vaultsPerAvailableProviders.filter((v) => options.chainIds.includes(v.chain))
|
|
82
129
|
: vaultsPerAvailableProviders;
|
|
130
|
+
// Fetch and transform (filter for active status)
|
|
83
131
|
const emberVaults = await this.suiService.getEmberVaults({
|
|
84
132
|
status: 'active',
|
|
85
133
|
});
|
|
@@ -93,11 +141,21 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
93
141
|
return constants_1.ALLOWED_SUI_VAULT_ADDRESSES.includes(normalizedAddress);
|
|
94
142
|
});
|
|
95
143
|
const transformedVaults = this.suiService.transformEmberVaultsToIVaults(whitelistedEmberVaults);
|
|
144
|
+
// Use comprehensive vault fetching for maximum coverage
|
|
96
145
|
const vaultFetchResult = await (0, fetcher_1.fetchVaultsComprehensive)(vaultsPerChainId, async (vault) => {
|
|
146
|
+
// Handle fallback RPC if provided
|
|
97
147
|
const rpcUrl = vault.fallbackRpc || this.providers?.[vault.chain];
|
|
98
|
-
|
|
148
|
+
// Closed vaults have no live loans/allocations. In portfolio mode,
|
|
149
|
+
// skip that enrichment so a closed vault is never dropped just because
|
|
150
|
+
// getVaultAllocations re-throws (no debank data / no subaccounts).
|
|
151
|
+
const isClosedVault = vault.status === 'closed';
|
|
152
|
+
const skipClosedEnrichment = !!options?.includeClosed && isClosedVault;
|
|
153
|
+
// Handle minimal data fetching
|
|
154
|
+
const shouldFetchLoans = !skipClosedEnrichment &&
|
|
155
|
+
!vault.minimal &&
|
|
99
156
|
(typeof options?.loans !== 'undefined' ? options?.loans : true);
|
|
100
|
-
const shouldFetchAllocations = !
|
|
157
|
+
const shouldFetchAllocations = !skipClosedEnrichment &&
|
|
158
|
+
!vault.minimal &&
|
|
101
159
|
(typeof options?.allocations !== 'undefined'
|
|
102
160
|
? options?.allocations
|
|
103
161
|
: true);
|
|
@@ -111,6 +169,9 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
111
169
|
env: this.monitoring?.env,
|
|
112
170
|
augustKey: this.keys?.august,
|
|
113
171
|
subgraphKey: this.keys?.graph,
|
|
172
|
+
// Portfolio mode: let the EVM getter resolve closed + invisible
|
|
173
|
+
// vaults instead of null-ing them, so the closed vault survives.
|
|
174
|
+
includeClosed: options?.includeClosed,
|
|
114
175
|
},
|
|
115
176
|
loadSubaccounts: options?.loadSubaccounts,
|
|
116
177
|
loadSnapshots: options?.loadSnapshots,
|
|
@@ -125,14 +186,17 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
125
186
|
includeInvisible: false,
|
|
126
187
|
timeout: 60000,
|
|
127
188
|
fallbackRpcUrls: {
|
|
189
|
+
// Use configured fallback RPC endpoints for each chain
|
|
128
190
|
1: (0, core_1.getFallbackRpcUrls)(1),
|
|
129
191
|
56: (0, core_1.getFallbackRpcUrls)(56),
|
|
130
192
|
43114: (0, core_1.getFallbackRpcUrls)(43114),
|
|
131
193
|
8453: (0, core_1.getFallbackRpcUrls)(8453),
|
|
132
194
|
42161: (0, core_1.getFallbackRpcUrls)(42161),
|
|
133
195
|
137: (0, core_1.getFallbackRpcUrls)(137),
|
|
196
|
+
// [SPECIAL_CHAINS.solana.chainId]: getFallbackRpcUrls(SPECIAL_CHAINS.solana.chainId),
|
|
134
197
|
},
|
|
135
198
|
});
|
|
199
|
+
// Log vault fetching results in DEV mode
|
|
136
200
|
core_1.Logger.log.info('getVaults', `Total: ${vaultFetchResult.coverageReport.totalVaults}, ` +
|
|
137
201
|
`Success: ${vaultFetchResult.coverageReport.successfulVaults}, ` +
|
|
138
202
|
`Failed: ${vaultFetchResult.coverageReport.failedVaults}, ` +
|
|
@@ -145,6 +209,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
145
209
|
attempts: f.attempts,
|
|
146
210
|
})));
|
|
147
211
|
}
|
|
212
|
+
// Use intelligent filtering to preserve more vaults
|
|
148
213
|
const vaultResponses = vaultFetchResult.successful
|
|
149
214
|
.sort((a, b) => a.index - b.index)
|
|
150
215
|
.map((item) => item.data);
|
|
@@ -153,13 +218,23 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
153
218
|
includeInvisible: true,
|
|
154
219
|
minStatus: ['active', 'closed'],
|
|
155
220
|
});
|
|
221
|
+
// Closed vaults are included in the result ONLY when the caller opts in via
|
|
222
|
+
// `includeClosed` (portfolio mode). By default they are dropped, so the
|
|
223
|
+
// marketplace / discovery callers never receive a closed vault and don't
|
|
224
|
+
// have to filter `status === 'closed'` themselves. The portfolio passes
|
|
225
|
+
// `includeClosed: true` so a user's position in a closed vault can be
|
|
226
|
+
// joined against this list. Note: closed + invisible vaults land in the
|
|
227
|
+
// `closed` bucket (the status check precedes the visibility check in
|
|
228
|
+
// filterVaultsIntelligently), so this single gate covers them too.
|
|
156
229
|
const filteredResponses = [
|
|
157
230
|
...filteredResults.active,
|
|
231
|
+
...(options?.includeClosed ? filteredResults.closed : []),
|
|
158
232
|
...filteredResults.invisible,
|
|
159
233
|
];
|
|
160
234
|
if ((options.wallet && (0, ethers_1.isAddress)(options.wallet)) ||
|
|
161
235
|
(options.solanaWallet &&
|
|
162
236
|
utils_1.SolanaUtils.isSolanaAddress(options.solanaWallet))) {
|
|
237
|
+
// fetch all positions for user wallet
|
|
163
238
|
const vaultResponses = await (0, core_1.promiseSettle)(vaultsPerAvailableProviders.map((v) => (0, getters_1.getVaultPositions)({
|
|
164
239
|
vault: v.address,
|
|
165
240
|
wallet: options.wallet,
|
|
@@ -172,7 +247,9 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
172
247
|
augustKey: this.keys?.august,
|
|
173
248
|
subgraphKey: this.keys?.graph,
|
|
174
249
|
},
|
|
175
|
-
})), 5,
|
|
250
|
+
})), 5, // 5 retries
|
|
251
|
+
2000);
|
|
252
|
+
// return vault object with position property
|
|
176
253
|
const positions = vaultResponses
|
|
177
254
|
.flat()
|
|
178
255
|
.filter((v) => v.status !== 'PENDING');
|
|
@@ -181,11 +258,18 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
181
258
|
position: positions?.find((pos) => pos.vault?.toLowerCase() === r.address?.toLowerCase()) || null,
|
|
182
259
|
}));
|
|
183
260
|
}
|
|
184
|
-
if (
|
|
261
|
+
if (options.wallet && !(0, ethers_1.isAddress)(options.wallet)) {
|
|
185
262
|
core_1.Logger.log.warn('getVaults:invalid_wallet', options.wallet);
|
|
186
263
|
}
|
|
264
|
+
// console.log(`#getVaults:`, filteredResponses);
|
|
187
265
|
return [...filteredResponses, ...transformedVaults];
|
|
188
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Calculate total deposited across all tokenized vaults by summing latest_reported_tvl.
|
|
269
|
+
* Uses the /tokenized_vault endpoint which returns latest_reported_tvl in USD.
|
|
270
|
+
* @param options Optional configuration for loading vaults
|
|
271
|
+
* @returns Total deposited amount in USD (sum of all latest_reported_tvl values)
|
|
272
|
+
*/
|
|
189
273
|
async getTotalDeposited(options) {
|
|
190
274
|
const allVaults = await (0, core_1.fetchTokenizedVaults)(undefined, this.headers, options?.loadSubaccounts, options?.loadSnapshots);
|
|
191
275
|
let total = 0;
|
|
@@ -199,15 +283,28 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
199
283
|
});
|
|
200
284
|
return total;
|
|
201
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Fetch detailed data for a single vault with optional enrichment.
|
|
288
|
+
* Automatically includes loans and allocations unless explicitly disabled.
|
|
289
|
+
* @param vault Vault contract address
|
|
290
|
+
* @param chainId Optional chain ID (uses active network if not provided)
|
|
291
|
+
* @param options Enrichment and wallet options
|
|
292
|
+
* @returns Single vault object with optional position data
|
|
293
|
+
*/
|
|
202
294
|
async getVault({ vault, chainId, options, loadSubaccounts, loadSnapshots, }) {
|
|
203
295
|
if (!vault)
|
|
204
296
|
throw new Error('Vault input parameter is undefined.');
|
|
297
|
+
// if (!isAddress(vault))
|
|
298
|
+
// throw new Error(
|
|
299
|
+
// `Vault input parameter is not an address: ${String(vault)}`,
|
|
300
|
+
// );
|
|
205
301
|
if (typeof chainId !== 'undefined') {
|
|
206
302
|
if (!this.providers?.[chainId]) {
|
|
207
303
|
const error = new Error(`Missing RPC URL for chainId ${chainId}`);
|
|
208
304
|
core_1.Logger.log.error('getVault:missing_provider', error, { chainId });
|
|
209
305
|
}
|
|
210
306
|
}
|
|
307
|
+
// get vault data
|
|
211
308
|
const vaultResponse = await (0, getters_1.getVault)({
|
|
212
309
|
vault: vault,
|
|
213
310
|
loans: typeof options?.loans !== 'undefined' ? options?.loans : true,
|
|
@@ -232,6 +329,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
232
329
|
(options?.solanaWallet &&
|
|
233
330
|
utils_1.SolanaUtils.isSolanaAddress(options?.solanaWallet)) ||
|
|
234
331
|
(options?.stellarWallet && (0, utils_2.isStellarAddress)(options?.stellarWallet)))) {
|
|
332
|
+
// fetch all positions for user wallet
|
|
235
333
|
const vaultResponses = await (0, getters_1.getVaultPositions)({
|
|
236
334
|
vault: vault,
|
|
237
335
|
solanaWallet: options?.solanaWallet,
|
|
@@ -248,18 +346,25 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
248
346
|
headers: this.headers,
|
|
249
347
|
},
|
|
250
348
|
});
|
|
349
|
+
// return vault object with position property
|
|
251
350
|
const positions = vaultResponses.filter((v) => v.status !== 'PENDING');
|
|
252
351
|
return {
|
|
253
352
|
...vaultResponse,
|
|
254
353
|
position: positions?.find((pos) => pos.vault?.toLowerCase() === vault?.toLowerCase()) || null,
|
|
255
354
|
};
|
|
256
355
|
}
|
|
257
|
-
if (
|
|
356
|
+
if (options?.wallet && !(0, ethers_1.isAddress)(options?.wallet)) {
|
|
258
357
|
core_1.Logger.log.warn('getVault:invalid_wallet', options?.wallet);
|
|
259
358
|
}
|
|
359
|
+
// console.log(`#getVault::${vaultResponse.symbol}:`, vaultResponse);
|
|
260
360
|
return vaultResponse;
|
|
261
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
*
|
|
364
|
+
*/
|
|
262
365
|
async getVaultLoans({ vault, chainId, }) {
|
|
366
|
+
// Sanitize
|
|
367
|
+
// if (!this.authorized) throw new Error('Not authorized.');
|
|
263
368
|
if (!vault)
|
|
264
369
|
throw new Error('Vault input parameter is undefined.');
|
|
265
370
|
if (!(0, ethers_1.isAddress)(vault))
|
|
@@ -270,6 +375,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
270
375
|
core_1.Logger.log.error('getVaultLoans:missing_provider', error, { chainId });
|
|
271
376
|
}
|
|
272
377
|
}
|
|
378
|
+
// get vault loans data
|
|
273
379
|
const vaultResponse = await (0, getters_1.getVaultLoans)(vault, {
|
|
274
380
|
rpcUrl: chainId
|
|
275
381
|
? this.providers?.[chainId]
|
|
@@ -283,7 +389,11 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
283
389
|
});
|
|
284
390
|
return vaultResponse;
|
|
285
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
*
|
|
394
|
+
*/
|
|
286
395
|
async getVaultSubaccountLoans({ vault, chainId, }) {
|
|
396
|
+
// Sanitize
|
|
287
397
|
if (!vault)
|
|
288
398
|
throw new Error('Vault input parameter is undefined.');
|
|
289
399
|
if (!(0, ethers_1.isAddress)(vault))
|
|
@@ -296,6 +406,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
296
406
|
});
|
|
297
407
|
}
|
|
298
408
|
}
|
|
409
|
+
// get vault subaccount loans data
|
|
299
410
|
const vaultResponse = await (0, getters_1.getVaultSubaccountLoans)(vault, {
|
|
300
411
|
rpcUrl: chainId
|
|
301
412
|
? this.providers?.[chainId]
|
|
@@ -309,7 +420,12 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
309
420
|
});
|
|
310
421
|
return vaultResponse;
|
|
311
422
|
}
|
|
423
|
+
/**
|
|
424
|
+
*
|
|
425
|
+
*/
|
|
312
426
|
async getVaultAllocations({ vault, chainId, }) {
|
|
427
|
+
// Sanitize
|
|
428
|
+
// if (!this.authorized) throw new Error('Not authorized.');
|
|
313
429
|
if (!vault)
|
|
314
430
|
throw new Error('Vault input parameter is undefined.');
|
|
315
431
|
if (!(0, ethers_1.isAddress)(vault) &&
|
|
@@ -324,6 +440,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
324
440
|
});
|
|
325
441
|
}
|
|
326
442
|
}
|
|
443
|
+
// get vault allocations data
|
|
327
444
|
try {
|
|
328
445
|
const vaultResponse = await (0, getters_1.getVaultAllocations)(vault, {
|
|
329
446
|
rpcUrl: chainId
|
|
@@ -351,7 +468,15 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
351
468
|
};
|
|
352
469
|
}
|
|
353
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* @deprecated use getVaultHistoricalTimeseries instead
|
|
473
|
+
* @function getVaultApy gets the vault/pool APR, both current and historical
|
|
474
|
+
* @param vault pool/vault contract address
|
|
475
|
+
* @param historical (optional) When passed, returns the historical records of the pool/vault APR
|
|
476
|
+
* @returns a value or array of objects containing the APR and timestamp
|
|
477
|
+
*/
|
|
354
478
|
async getVaultApy({ vault, historical, }) {
|
|
479
|
+
// if (!this.authorized) throw new Error('Not authorized.');
|
|
355
480
|
if (!vault)
|
|
356
481
|
throw new Error('Vault input parameter is undefined.');
|
|
357
482
|
if (!(0, ethers_1.isAddress)(vault) && !(0, utils_2.isStellarAddress)(vault))
|
|
@@ -366,6 +491,12 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
366
491
|
},
|
|
367
492
|
});
|
|
368
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* @function getVaultHistoricalTimeseries gets historical timeseries data for a vault
|
|
496
|
+
* @param vault Vault contract address
|
|
497
|
+
* @param nDays Number of days of historical data (default 30, min 1)
|
|
498
|
+
* @returns Historical timeseries data with TVL, APY, PnL, share price, and other metrics
|
|
499
|
+
*/
|
|
369
500
|
async getVaultHistoricalTimeseries({ vault, nDays, }) {
|
|
370
501
|
if (!vault)
|
|
371
502
|
throw new Error('Vault input parameter is undefined.');
|
|
@@ -378,6 +509,9 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
378
509
|
},
|
|
379
510
|
});
|
|
380
511
|
}
|
|
512
|
+
/**
|
|
513
|
+
*
|
|
514
|
+
*/
|
|
381
515
|
async getVaultAvailableRedemptions({ vault, chainId, wallet, verbose, }) {
|
|
382
516
|
if (!this.authorized)
|
|
383
517
|
throw new Error('Not authorized.');
|
|
@@ -401,6 +535,35 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
401
535
|
},
|
|
402
536
|
});
|
|
403
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* Historical redemption requests for a vault (settled, cancelled, and
|
|
540
|
+
* pending-but-out-of-window). Filterable by wallet.
|
|
541
|
+
*
|
|
542
|
+
* Stellar vaults return `[]` — on-chain redemption history is not yet
|
|
543
|
+
* indexed for that adapter.
|
|
544
|
+
*
|
|
545
|
+
* @param vault - Vault address (EVM or Stellar). Stellar input is
|
|
546
|
+
* accepted but always resolves to an empty array for now.
|
|
547
|
+
* @param chainId - Chain id to resolve the RPC URL against. Falls
|
|
548
|
+
* back to the active network.
|
|
549
|
+
* @param wallet - Optional EVM wallet filter; when omitted the
|
|
550
|
+
* response includes every wallet that has ever redeemed against
|
|
551
|
+
* the vault.
|
|
552
|
+
* @param lookbackBlocks - How far back to scan for redemption logs.
|
|
553
|
+
* Defaults to the SDK's internal lookback when omitted.
|
|
554
|
+
* @returns The same array shape `getVaultRedemptionHistory` returns
|
|
555
|
+
* at the module level — historical redemption records, newest
|
|
556
|
+
* first.
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* ```ts
|
|
560
|
+
* const history = await sdk.vaultsModule.getVaultRedemptionHistory({
|
|
561
|
+
* vault: '0xVault',
|
|
562
|
+
* chainId: 8453,
|
|
563
|
+
* wallet: '0xWallet',
|
|
564
|
+
* });
|
|
565
|
+
* ```
|
|
566
|
+
*/
|
|
404
567
|
async getVaultRedemptionHistory({ vault, chainId, wallet, lookbackBlocks, }) {
|
|
405
568
|
if (!this.authorized)
|
|
406
569
|
throw new Error('Not authorized.');
|
|
@@ -424,10 +587,16 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
424
587
|
},
|
|
425
588
|
});
|
|
426
589
|
}
|
|
590
|
+
/**
|
|
591
|
+
*
|
|
592
|
+
*/
|
|
427
593
|
async getVaultPositions({ vault, wallet, chainId, showAllVaults, solanaWallet, stellarWallet, options, }) {
|
|
594
|
+
// if (!this.authorized) throw new Error('Not authorized.');
|
|
595
|
+
// Validate that at least one wallet type is provided
|
|
428
596
|
if (solanaWallet && !utils_1.SolanaUtils.isSolanaAddress(solanaWallet)) {
|
|
429
597
|
throw new Error('Solana wallet parameter must be provided and be a valid Solana address');
|
|
430
598
|
}
|
|
599
|
+
// Validate EVM wallet if provided
|
|
431
600
|
if (wallet && !(0, ethers_1.isAddress)(wallet)) {
|
|
432
601
|
throw new Error(`Wallet parameter is not a valid address: ${String(wallet)}`);
|
|
433
602
|
}
|
|
@@ -478,7 +647,16 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
478
647
|
core_1.Logger.log.info(`getPositions::${chainId || 'all'}:`, final.map((v) => v.vault));
|
|
479
648
|
return final;
|
|
480
649
|
}
|
|
481
|
-
const vaultsPerAvailableProviders = allVaults.filter((v) =>
|
|
650
|
+
const vaultsPerAvailableProviders = allVaults.filter((v) =>
|
|
651
|
+
// Stellar vaults are backend-only (no RPC provider required)
|
|
652
|
+
v?.chain_type === 'stellar' ||
|
|
653
|
+
// Solana vaults use this.solanaService (not this.providers). Without
|
|
654
|
+
// this clause every Solana position is dropped on any instance where
|
|
655
|
+
// ACTIVE_RPC_URLS() doesn't register chainId -1 — which is exactly
|
|
656
|
+
// how the jitoSOL "missing position" regression manifested. Gate on
|
|
657
|
+
// solanaService presence so we don't pass Solana vaults through with
|
|
658
|
+
// no adapter to read them — the inner getter would crash, hit the
|
|
659
|
+
// outer catch, and silently return PENDING (then get filtered out).
|
|
482
660
|
(v?.chain_type === 'solana' && !!this.solanaService) ||
|
|
483
661
|
(this.providers?.[v?.chain] ? true : false));
|
|
484
662
|
const vaultResponses = await Promise.all(vaultsPerAvailableProviders.map((v) => (0, getters_1.getVaultPositions)({
|
|
@@ -501,15 +679,23 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
501
679
|
final = flattened;
|
|
502
680
|
else
|
|
503
681
|
final = flattened.filter((v) => v?.status !== 'PENDING');
|
|
682
|
+
// console.log(`#getPositions::${chainId || 'all'}:`, final);
|
|
504
683
|
return final;
|
|
505
684
|
}
|
|
685
|
+
/**
|
|
686
|
+
*
|
|
687
|
+
*/
|
|
506
688
|
async getUserHistory({ wallet, chainId, vault, }) {
|
|
689
|
+
// Santize
|
|
690
|
+
// if (!this.authorized) throw new Error('Not authorized.');
|
|
507
691
|
if (!(0, ethers_1.isAddress)(wallet))
|
|
508
692
|
throw new Error(`Wallet parameter is not an address: ${String(wallet)}`);
|
|
693
|
+
// Get Chain ID — required for subgraph queries
|
|
509
694
|
const _chainId = chainId || this.activeNetwork?.chainId;
|
|
510
695
|
if (!_chainId) {
|
|
511
696
|
throw new Error('Chain ID is required for getUserHistory. Pass chainId explicitly or configure an active network.');
|
|
512
697
|
}
|
|
698
|
+
// Format history initialization
|
|
513
699
|
let finalArray = [];
|
|
514
700
|
function formatHistory(history) {
|
|
515
701
|
return history.map((h) => ({
|
|
@@ -522,10 +708,17 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
522
708
|
transactionHash: h.transactionHash_,
|
|
523
709
|
}));
|
|
524
710
|
}
|
|
711
|
+
// Helper function to fetch history for a vault
|
|
712
|
+
// For LayerZero-enabled vaults (coreUSDC, upUSDC), queries BOTH the standard
|
|
713
|
+
// subgraph and the LayerZero subgraph, since deposits can be either same-chain
|
|
714
|
+
// or cross-chain via LayerZero
|
|
525
715
|
const fetchVaultHistory = async (vaultAddress, vaultChainId) => {
|
|
716
|
+
// Always query the standard subgraph
|
|
526
717
|
const provider = (0, core_1.createProvider)(this.providers?.[vaultChainId]);
|
|
527
718
|
const standardHistory = await (0, vaults_1.getSubgraphUserHistory)(wallet, provider, vaultAddress);
|
|
528
719
|
const formattedStandard = formatHistory(standardHistory);
|
|
720
|
+
// If this vault also supports LayerZero cross-chain deposits,
|
|
721
|
+
// query the LayerZero subgraph and merge results
|
|
529
722
|
const layerZeroVaultKey = (0, deposits_1.isLayerZeroVault)(vaultAddress);
|
|
530
723
|
if (layerZeroVaultKey) {
|
|
531
724
|
try {
|
|
@@ -539,6 +732,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
539
732
|
type: 'deposit',
|
|
540
733
|
transactionHash: deposit.transactionHash_,
|
|
541
734
|
}));
|
|
735
|
+
// For earnAUSD, also query LayerZero redeems
|
|
542
736
|
let formattedLayerZeroRedeems = [];
|
|
543
737
|
if (layerZeroVaultKey === 'earnAUSD') {
|
|
544
738
|
try {
|
|
@@ -557,6 +751,9 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
557
751
|
core_1.Logger.log.warn('getUserHistory:layerzero:redeems', `Failed to fetch LayerZero redeems for earnAUSD: ${redeemError.message}`);
|
|
558
752
|
}
|
|
559
753
|
}
|
|
754
|
+
// Deduplicate against standard subgraph history only — LZ deposits and
|
|
755
|
+
// LZ redeems are not deduped against each other because a single tx can
|
|
756
|
+
// legitimately emit both a Deposited and a Redeemed event.
|
|
560
757
|
const seenTxHashes = new Set(formattedStandard.map((h) => h.transactionHash?.toLowerCase()));
|
|
561
758
|
const uniqueLayerZero = formattedLayerZero.filter((h) => !seenTxHashes.has(h.transactionHash?.toLowerCase()));
|
|
562
759
|
const uniqueLayerZeroRedeems = formattedLayerZeroRedeems.filter((h) => !seenTxHashes.has(h.transactionHash?.toLowerCase()));
|
|
@@ -567,17 +764,21 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
567
764
|
];
|
|
568
765
|
}
|
|
569
766
|
catch (error) {
|
|
767
|
+
// If LayerZero query fails, still return standard history
|
|
570
768
|
core_1.Logger.log.warn('getUserHistory:layerzero', `Failed to fetch LayerZero deposits for ${layerZeroVaultKey}: ${error.message}`);
|
|
571
769
|
return formattedStandard;
|
|
572
770
|
}
|
|
573
771
|
}
|
|
574
772
|
return formattedStandard;
|
|
575
773
|
};
|
|
774
|
+
// If vault is provided, return history for that vault
|
|
576
775
|
if (vault) {
|
|
577
776
|
finalArray = await fetchVaultHistory(vault, chainId);
|
|
578
777
|
}
|
|
579
778
|
else {
|
|
779
|
+
// Fetch all vaults
|
|
580
780
|
const allVaults = await (0, core_1.fetchTokenizedVaults)(undefined, this.headers, false, false);
|
|
781
|
+
// If chainId is provided, return history for all vaults on that chain
|
|
581
782
|
if (chainId) {
|
|
582
783
|
const vaultsPerChain = allVaults.filter((v) => v.chain === chainId);
|
|
583
784
|
const vaultResponses = await Promise.all(vaultsPerChain.map((v) => fetchVaultHistory(v.address, v.chain)));
|
|
@@ -585,6 +786,8 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
585
786
|
finalArray = flattened;
|
|
586
787
|
}
|
|
587
788
|
else {
|
|
789
|
+
// Else, fetch all history for all vaults across all initialized chains
|
|
790
|
+
// LayerZero vaults query subgraphs directly and don't need a provider
|
|
588
791
|
const vaultsPerAvailableProviders = allVaults.filter((v) => this.providers?.[v?.chain] || (0, deposits_1.isLayerZeroVault)(v.address));
|
|
589
792
|
const vaultResponses = await Promise.all(vaultsPerAvailableProviders.map((v) => fetchVaultHistory(v.address, v.chain)));
|
|
590
793
|
const flattened = vaultResponses.flat();
|
|
@@ -594,6 +797,11 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
594
797
|
core_1.Logger.log.info('getUserHistory', `${wallet}::${finalArray.length}`);
|
|
595
798
|
return finalArray;
|
|
596
799
|
}
|
|
800
|
+
/**
|
|
801
|
+
* Get lifetime PnL for a user in a specific vault.
|
|
802
|
+
* @param props Vault address, wallet address, and optional chain ID
|
|
803
|
+
* @returns Lifetime PnL data including realized and unrealized PnL
|
|
804
|
+
*/
|
|
597
805
|
async getVaultUserLifetimePnl({ vault, wallet, chainId, }) {
|
|
598
806
|
if (!(0, ethers_1.isAddress)(wallet))
|
|
599
807
|
throw new Error(`Wallet parameter is not an address: ${String(wallet)}`);
|
|
@@ -616,6 +824,12 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
616
824
|
coingeckoKey: this.keys?.coingecko,
|
|
617
825
|
});
|
|
618
826
|
}
|
|
827
|
+
/**
|
|
828
|
+
* Get PnL for a vault (vault-level, not user-specific).
|
|
829
|
+
* Returns the vault's overall profit and loss across all users.
|
|
830
|
+
* @param props Vault address and optional chain ID
|
|
831
|
+
* @returns Vault PnL in USD and notional value
|
|
832
|
+
*/
|
|
619
833
|
async getVaultPnl({ vault, chainId, }) {
|
|
620
834
|
if (!(0, ethers_1.isAddress)(vault))
|
|
621
835
|
throw new Error(`Vault parameter is not an address: ${String(vault)}`);
|
|
@@ -634,9 +848,15 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
634
848
|
},
|
|
635
849
|
});
|
|
636
850
|
}
|
|
851
|
+
/**
|
|
852
|
+
*
|
|
853
|
+
*/
|
|
637
854
|
async getUserTransfers({ wallet, chainId, vault, options, }) {
|
|
855
|
+
// Santize
|
|
856
|
+
// if (!this.authorized) throw new Error('Not authorized.');
|
|
638
857
|
if (!(0, ethers_1.isAddress)(wallet))
|
|
639
858
|
throw new Error(`Wallet parameter is not an address: ${String(wallet)}`);
|
|
859
|
+
// Format history initialization
|
|
640
860
|
let finalArray = [];
|
|
641
861
|
function formatTransfers(transfers) {
|
|
642
862
|
return transfers.map((t) => ({
|
|
@@ -650,13 +870,16 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
650
870
|
transactionHash: t.transactionHash_,
|
|
651
871
|
}));
|
|
652
872
|
}
|
|
873
|
+
// If vault is provided, return history for that vault
|
|
653
874
|
if (vault) {
|
|
654
875
|
const provider = (0, core_1.createProvider)(this.providers?.[chainId]);
|
|
655
876
|
const userHistory = await (0, vaults_1.getSubgraphUserTransfers)(wallet, provider, vault);
|
|
656
877
|
finalArray = formatTransfers(userHistory);
|
|
657
878
|
}
|
|
658
879
|
else {
|
|
880
|
+
// Fetch all vaults
|
|
659
881
|
const allVaults = await (0, core_1.fetchTokenizedVaults)(undefined, this.headers, false, false);
|
|
882
|
+
// If chainId is provided, return history for all vaults on that chain
|
|
660
883
|
if (chainId) {
|
|
661
884
|
const vaultsPerChain = allVaults.filter((v) => v.chain === chainId);
|
|
662
885
|
const vaultResponses = await Promise.all(vaultsPerChain.map(async (v) => {
|
|
@@ -668,6 +891,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
668
891
|
finalArray = formatTransfers(flattened);
|
|
669
892
|
}
|
|
670
893
|
else {
|
|
894
|
+
// Else, fetch all history for all vaults across all initialized chains
|
|
671
895
|
const vaultsPerAvailableProviders = allVaults.filter((v) => this.providers?.[v?.chain] ? true : false);
|
|
672
896
|
const vaultResponses = await Promise.all(vaultsPerAvailableProviders.map(async (v) => {
|
|
673
897
|
const provider = (0, core_1.createProvider)(this.providers?.[v.chain]);
|
|
@@ -681,6 +905,12 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
681
905
|
core_1.Logger.log.info('getUserTransfers', `${wallet}::${finalArray.length}`);
|
|
682
906
|
return finalArray;
|
|
683
907
|
}
|
|
908
|
+
/**
|
|
909
|
+
* @function getStakingPositions gets all available reward staking positions
|
|
910
|
+
* @param wallet optionally passed user wallet address
|
|
911
|
+
* @param chainId optionally passed chainId
|
|
912
|
+
* @returns all available staking positions for connected or passed network(s)
|
|
913
|
+
*/
|
|
684
914
|
async getStakingPositions(wallet, chainId) {
|
|
685
915
|
if (chainId) {
|
|
686
916
|
const positions = await (0, getters_1.getRewardsStakingPositions)({
|
|
@@ -699,6 +929,12 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
699
929
|
}));
|
|
700
930
|
return positions.flat();
|
|
701
931
|
}
|
|
932
|
+
/**
|
|
933
|
+
* @function getVaultTvl gets the vault/pool TVL, both current and historical
|
|
934
|
+
* @param vault pool/vault contract address
|
|
935
|
+
* @param historical (optional) When passed, returns the historical records of the pool/vault TVL
|
|
936
|
+
* @returns an object or array of objects containing the TVL and timestamp
|
|
937
|
+
*/
|
|
702
938
|
async getVaultTvl({ vault, chainId, historical, }) {
|
|
703
939
|
if (!this.authorized)
|
|
704
940
|
throw new Error('Not authorized.');
|
|
@@ -724,6 +960,12 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
724
960
|
historical: historical,
|
|
725
961
|
});
|
|
726
962
|
}
|
|
963
|
+
/**
|
|
964
|
+
* @function getYieldLastRealizedOn gets the timestamp when yield was last realized for a vault
|
|
965
|
+
* @param vault Vault contract address
|
|
966
|
+
* @param chainId Optional chain ID (uses active network if not provided)
|
|
967
|
+
* @returns Timestamp (Unix timestamp in seconds) when yield was last realized
|
|
968
|
+
*/
|
|
727
969
|
async getYieldLastRealizedOn({ vault, chainId, }) {
|
|
728
970
|
const rpcUrl = chainId
|
|
729
971
|
? this.providers?.[chainId]
|
|
@@ -740,6 +982,27 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
740
982
|
},
|
|
741
983
|
});
|
|
742
984
|
}
|
|
985
|
+
/**
|
|
986
|
+
* Gets borrower health-factor data for vaults on a chain, optionally
|
|
987
|
+
* scoped to a single vault.
|
|
988
|
+
*
|
|
989
|
+
* Pass `vault` whenever the caller knows which pool it cares about —
|
|
990
|
+
* this skips the all-vaults cross-chain fanout and only reads the loans
|
|
991
|
+
* for that one pool. The response map is keyed by **lowercased** vault
|
|
992
|
+
* address; look entries up with `address.toLowerCase()`.
|
|
993
|
+
*
|
|
994
|
+
* Individual loan failures (bad/test loan contracts, unrecognized
|
|
995
|
+
* borrowers) are isolated and logged rather than rejecting the batch.
|
|
996
|
+
*
|
|
997
|
+
* @param chainId Optional chain to scope the read to. When omitted,
|
|
998
|
+
* iterates the SDK's configured providers and returns the flattened
|
|
999
|
+
* list (legacy shape — prefer passing a chain).
|
|
1000
|
+
* @param vault Optional vault address. When provided alongside
|
|
1001
|
+
* `chainId`, only that vault's data is fetched.
|
|
1002
|
+
* @returns When `chainId` is set, an object map of lowercased vault
|
|
1003
|
+
* address → array of borrower-health-factor rows. When `chainId` is
|
|
1004
|
+
* omitted, a flat array (legacy behavior, kept for backward compat).
|
|
1005
|
+
*/
|
|
743
1006
|
async getVaultBorrowerHealthFactor(chainId, vault) {
|
|
744
1007
|
if (chainId) {
|
|
745
1008
|
const health_factors = await (0, getters_1.getHealthFactorOfBorrowersByVault)({
|
|
@@ -769,6 +1032,11 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
769
1032
|
}));
|
|
770
1033
|
return health_factors.flat();
|
|
771
1034
|
}
|
|
1035
|
+
/**
|
|
1036
|
+
* @function getUserPoints fetches user points from the backend API
|
|
1037
|
+
* @param userAddress User wallet address
|
|
1038
|
+
* @returns Points data from the backend API
|
|
1039
|
+
*/
|
|
772
1040
|
async getUserPoints(userAddress) {
|
|
773
1041
|
const { getUserPoints } = await Promise.resolve().then(() => __importStar(require('./getters')));
|
|
774
1042
|
return await getUserPoints({
|
|
@@ -782,6 +1050,22 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
782
1050
|
},
|
|
783
1051
|
});
|
|
784
1052
|
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Register a user for the points program, authenticated by a wallet signature.
|
|
1055
|
+
*
|
|
1056
|
+
* The caller produces a personal_sign signature over a canonical message
|
|
1057
|
+
* built from these primitives — see `registerUserForPoints` in
|
|
1058
|
+
* `./getters` for the exact template and a worked example.
|
|
1059
|
+
*
|
|
1060
|
+
* @param userAddress EVM wallet address being registered.
|
|
1061
|
+
* @param referrerAddress Optional referrer EVM address.
|
|
1062
|
+
* @param chainId Chain on which the wallet signed; powers the EIP-1271
|
|
1063
|
+
* fallback for smart-contract wallets and pins the signature cross-chain.
|
|
1064
|
+
* @param signature 0x-prefixed hex personal_sign signature over the canonical message.
|
|
1065
|
+
* @param nonce Single-use random string (8–128 chars).
|
|
1066
|
+
* @param expiry Unix seconds; must be in the future, within the backend's TTL.
|
|
1067
|
+
* @returns Raw `Response` from the backend.
|
|
1068
|
+
*/
|
|
785
1069
|
async registerUserForPoints(userAddress, referrerAddress, chainId, signature, nonce, expiry) {
|
|
786
1070
|
const { registerUserForPoints } = await Promise.resolve().then(() => __importStar(require('./getters')));
|
|
787
1071
|
return await registerUserForPoints({
|
|
@@ -800,6 +1084,11 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
800
1084
|
},
|
|
801
1085
|
});
|
|
802
1086
|
}
|
|
1087
|
+
/**
|
|
1088
|
+
* @function fetchPointsLeaderboard fetches the points leaderboard data
|
|
1089
|
+
* @param params Optional parameters for pagination and sorting
|
|
1090
|
+
* @returns Leaderboard response data
|
|
1091
|
+
*/
|
|
803
1092
|
async fetchPointsLeaderboard(params) {
|
|
804
1093
|
const { fetchPointsLeaderboard } = await Promise.resolve().then(() => __importStar(require('./getters')));
|
|
805
1094
|
return await fetchPointsLeaderboard({
|
|
@@ -813,6 +1102,18 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
813
1102
|
},
|
|
814
1103
|
});
|
|
815
1104
|
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Get annualized APY metrics for a vault.
|
|
1107
|
+
*
|
|
1108
|
+
* Supported Vaults: cUSDO, tETH, wstETH, rsETH
|
|
1109
|
+
*
|
|
1110
|
+
* @deprecated The `hgETH30dLiquidAPY` and `hgETH7dLiquidAPY` response fields are deprecated.
|
|
1111
|
+
* These fields will be removed on 2026-01-01.
|
|
1112
|
+
* Use `liquidAPY30Day` and `liquidAPY7Day` fields instead.
|
|
1113
|
+
*
|
|
1114
|
+
* @param vault Vault address
|
|
1115
|
+
* @returns Annualized APY data including liquidity APY
|
|
1116
|
+
*/
|
|
816
1117
|
async getVaultAnnualizedApy(vault) {
|
|
817
1118
|
if (!vault)
|
|
818
1119
|
throw new Error('Vault address parameter is undefined.');
|
|
@@ -831,6 +1132,11 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
831
1132
|
},
|
|
832
1133
|
});
|
|
833
1134
|
}
|
|
1135
|
+
/**
|
|
1136
|
+
* Get summary data for a vault (name, type, chain, recent returns).
|
|
1137
|
+
* @param vault Vault address
|
|
1138
|
+
* @returns Vault summary data
|
|
1139
|
+
*/
|
|
834
1140
|
async getVaultSummary(vault) {
|
|
835
1141
|
if (!vault)
|
|
836
1142
|
throw new Error('Vault address parameter is undefined.');
|
|
@@ -849,6 +1155,12 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
849
1155
|
},
|
|
850
1156
|
});
|
|
851
1157
|
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Get withdrawal summary and pending queue for a vault.
|
|
1160
|
+
* @param vault Vault address
|
|
1161
|
+
* @param chainId Chain ID (will be converted to chain name)
|
|
1162
|
+
* @returns Withdrawal summary and pending queue
|
|
1163
|
+
*/
|
|
852
1164
|
async getVaultWithdrawals(vault, chainId) {
|
|
853
1165
|
if (!vault)
|
|
854
1166
|
throw new Error('Vault address parameter is undefined.');
|
|
@@ -869,6 +1181,13 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
869
1181
|
},
|
|
870
1182
|
});
|
|
871
1183
|
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Fetch pending redemptions for a vault with liquidity analysis.
|
|
1186
|
+
* @param vault - Vault contract address
|
|
1187
|
+
* @param pastDays - Number of past days to include (default 7, min 1, max 30)
|
|
1188
|
+
* @param futureDays - Number of future days to include (default 14, min 1, max 30)
|
|
1189
|
+
* @returns Pending redemptions grouped by date with liquidity summary
|
|
1190
|
+
*/
|
|
872
1191
|
async getVaultPendingRedemptions({ vault, pastDays, futureDays, }) {
|
|
873
1192
|
if (!vault)
|
|
874
1193
|
throw new Error('Vault address parameter is undefined.');
|
|
@@ -888,6 +1207,13 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
888
1207
|
},
|
|
889
1208
|
});
|
|
890
1209
|
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Preview the amount of assets that would be received for redeeming shares (queued redemption).
|
|
1212
|
+
* @param vault Vault contract address
|
|
1213
|
+
* @param sharesAmount Amount of shares to redeem (human-readable, raw bigint, or string)
|
|
1214
|
+
* @param chainId Optional chain ID (uses active network if not provided)
|
|
1215
|
+
* @returns The amount of assets as INormalizedNumber { normalized, raw }
|
|
1216
|
+
*/
|
|
891
1217
|
async previewRedemption({ vault, sharesAmount, chainId, }) {
|
|
892
1218
|
const rpcUrl = chainId
|
|
893
1219
|
? this.providers?.[chainId]
|
|
@@ -901,6 +1227,28 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
901
1227
|
},
|
|
902
1228
|
});
|
|
903
1229
|
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Get all withdrawal requests for a vault with deterministic status tracking.
|
|
1232
|
+
*
|
|
1233
|
+
* Matches requests to processed events by `(receiver, claimableDate)` tuple.
|
|
1234
|
+
*
|
|
1235
|
+
* **Status values:**
|
|
1236
|
+
* - `'processed'` — Matching `WithdrawalProcessed` event found on-chain.
|
|
1237
|
+
* - `'ready_to_claim'` — Claimable date has passed, no processed event found yet.
|
|
1238
|
+
* - `'pending'` — Claimable date is still in the future.
|
|
1239
|
+
*
|
|
1240
|
+
* **Lookback window:** Processed events are fetched from on-chain logs, which
|
|
1241
|
+
* only cover a finite block range. Requests whose claimable date is older than
|
|
1242
|
+
* this window with no matching processed event are excluded (assumed already
|
|
1243
|
+
* processed). Use `lookbackBlocks` to widen or narrow the scan range.
|
|
1244
|
+
*
|
|
1245
|
+
* @param vault - Vault contract address
|
|
1246
|
+
* @param receiver - Optional receiver address to filter by
|
|
1247
|
+
* @param lookbackBlocks - Optional on-chain log lookback window in blocks.
|
|
1248
|
+
* Defaults to chain-specific value (e.g. 150,000 for Ethereum, 3,456,000 for Monad).
|
|
1249
|
+
* @param chainId - Optional chain id for the vault address
|
|
1250
|
+
* @returns Array of withdrawal requests with status and claimable dates
|
|
1251
|
+
*/
|
|
904
1252
|
async getWithdrawalRequestsWithStatus(vault, receiver, lookbackBlocks, chainId) {
|
|
905
1253
|
if (!vault)
|
|
906
1254
|
throw new Error('Vault address parameter is undefined.');
|
|
@@ -923,9 +1271,23 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
923
1271
|
},
|
|
924
1272
|
});
|
|
925
1273
|
}
|
|
1274
|
+
/**
|
|
1275
|
+
* Redeem vault shares for an underlying asset via instant redemption (RWA subaccount).
|
|
1276
|
+
* Resolves the vault address to the RwaRedeemSubaccount internally.
|
|
1277
|
+
* Handles vault share approval automatically.
|
|
1278
|
+
* @param signer - Signer / wallet object
|
|
1279
|
+
* @param vault - Vault contract address
|
|
1280
|
+
* @param asset - Redeemable asset address (e.g. USDC, USDT)
|
|
1281
|
+
* @param amount - Amount of vault shares to redeem
|
|
1282
|
+
* @param minOut - Minimum output amount in output asset units (slippage protection)
|
|
1283
|
+
* @param chainId - Optional chain ID (uses active network if not provided)
|
|
1284
|
+
* @param wait - Wait for transaction confirmation
|
|
1285
|
+
* @returns transaction hash
|
|
1286
|
+
*/
|
|
926
1287
|
async rwaRedeemAsset(signer, { vault, asset, amount, minOut, chainId, wait, }) {
|
|
927
1288
|
if (!vault)
|
|
928
1289
|
throw new Error('Vault address parameter is undefined.');
|
|
1290
|
+
// Fetch vault data to resolve subaccount address and decimals
|
|
929
1291
|
const vaultData = await (0, getters_1.getVault)({
|
|
930
1292
|
vault,
|
|
931
1293
|
loans: false,
|
|
@@ -945,6 +1307,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
945
1307
|
throw new Error(`Vault ${vault} does not support instant redemption.`);
|
|
946
1308
|
}
|
|
947
1309
|
const { subaccountAddress, redeemableAssets } = vaultData.instant_redeem_config;
|
|
1310
|
+
// Resolve output asset decimals from config
|
|
948
1311
|
const redeemableAsset = redeemableAssets.find((a) => a.address.toLowerCase() === asset.toLowerCase());
|
|
949
1312
|
if (!redeemableAsset) {
|
|
950
1313
|
throw new Error(`Asset ${asset} is not redeemable for vault ${vault}.`);
|
|
@@ -961,12 +1324,22 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
961
1324
|
wait,
|
|
962
1325
|
});
|
|
963
1326
|
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Preview the output amount for an RWA instant redemption.
|
|
1329
|
+
* Resolves the vault address to the RwaRedeemSubaccount internally.
|
|
1330
|
+
* @param vault - Vault contract address
|
|
1331
|
+
* @param asset - Redeemable asset address (e.g. USDC, USDT)
|
|
1332
|
+
* @param amount - Amount of vault shares to preview
|
|
1333
|
+
* @param chainId - Optional chain ID (uses active network if not provided)
|
|
1334
|
+
* @returns normalized number of the expected output amount (in output asset decimals)
|
|
1335
|
+
*/
|
|
964
1336
|
async previewRwaRedemption({ vault, asset, amount, chainId, }) {
|
|
965
1337
|
if (!vault)
|
|
966
1338
|
throw new Error('Vault address parameter is undefined.');
|
|
967
1339
|
const rpcUrl = chainId
|
|
968
1340
|
? this.providers?.[chainId]
|
|
969
1341
|
: this.activeNetwork.rpcUrl;
|
|
1342
|
+
// Fetch vault data to resolve subaccount address and decimals
|
|
970
1343
|
const vaultData = await (0, getters_1.getVault)({
|
|
971
1344
|
vault,
|
|
972
1345
|
loans: false,
|
|
@@ -986,6 +1359,7 @@ class AugustVaults extends core_1.AugustBase {
|
|
|
986
1359
|
throw new Error(`Vault ${vault} does not support instant redemption.`);
|
|
987
1360
|
}
|
|
988
1361
|
const { subaccountAddress, redeemableAssets } = vaultData.instant_redeem_config;
|
|
1362
|
+
// Resolve output asset decimals from config
|
|
989
1363
|
const redeemableAsset = redeemableAssets.find((a) => a.address.toLowerCase() === asset.toLowerCase());
|
|
990
1364
|
if (!redeemableAsset) {
|
|
991
1365
|
throw new Error(`Asset ${asset} is not redeemable for vault ${vault}.`);
|