@augustdigital/sdk 8.3.1 → 8.5.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/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 +262 -0
- package/lib/adapters/evm/index.js +268 -1
- package/lib/adapters/evm/utils.d.ts +6 -0
- package/lib/adapters/evm/utils.js +7 -0
- package/lib/adapters/solana/constants.js +4 -1
- package/lib/adapters/solana/getters.d.ts +8 -0
- 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 +55 -0
- package/lib/adapters/solana/index.js +57 -0
- package/lib/adapters/solana/utils.d.ts +28 -0
- package/lib/adapters/solana/utils.js +79 -4
- package/lib/adapters/solana/vault.actions.d.ts +19 -0
- package/lib/adapters/solana/vault.actions.js +47 -3
- package/lib/adapters/stellar/actions.d.ts +25 -0
- 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 +48 -0
- package/lib/adapters/stellar/index.js +48 -0
- package/lib/adapters/stellar/soroban.d.ts +20 -0
- package/lib/adapters/stellar/soroban.js +46 -0
- package/lib/adapters/stellar/submit.d.ts +12 -0
- package/lib/adapters/stellar/submit.js +19 -0
- 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 +6 -0
- package/lib/adapters/sui/getters.js +6 -0
- package/lib/adapters/sui/index.d.ts +15 -0
- package/lib/adapters/sui/index.js +15 -0
- package/lib/adapters/sui/transformer.d.ts +6 -0
- package/lib/adapters/sui/transformer.js +7 -0
- 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 +19 -0
- package/lib/core/analytics/sentry.d.ts +45 -0
- package/lib/core/analytics/sentry.js +115 -2
- package/lib/core/analytics/types.d.ts +27 -0
- package/lib/core/analytics/user-identity.d.ts +34 -0
- package/lib/core/analytics/user-identity.js +42 -0
- 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 +75 -0
- package/lib/core/base.class.js +56 -0
- package/lib/core/cache.d.ts +5 -0
- package/lib/core/cache.js +6 -0
- package/lib/core/constants/adapters.d.ts +15 -0
- package/lib/core/constants/adapters.js +28 -8
- package/lib/core/constants/core.d.ts +12 -1
- package/lib/core/constants/core.js +12 -0
- package/lib/core/constants/swap-router.d.ts +46 -0
- package/lib/core/constants/swap-router.js +50 -0
- package/lib/core/constants/vaults.d.ts +56 -0
- package/lib/core/constants/vaults.js +66 -1
- package/lib/core/constants/web3.d.ts +3 -0
- package/lib/core/constants/web3.js +18 -5
- package/lib/core/errors/index.d.ts +36 -0
- package/lib/core/errors/index.js +29 -0
- package/lib/core/fetcher.d.ts +134 -0
- package/lib/core/fetcher.js +191 -5
- package/lib/core/helpers/adapters.d.ts +9 -0
- 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 +42 -0
- package/lib/core/helpers/core.js +66 -1
- package/lib/core/helpers/explorer-link.d.ts +14 -0
- package/lib/core/helpers/explorer-link.js +14 -0
- package/lib/core/helpers/signer.d.ts +26 -0
- package/lib/core/helpers/signer.js +39 -0
- package/lib/core/helpers/swap-router.d.ts +32 -0
- package/lib/core/helpers/swap-router.js +32 -0
- package/lib/core/helpers/vault-version.d.ts +1 -0
- package/lib/core/helpers/vault-version.js +2 -0
- package/lib/core/helpers/vaults.d.ts +8 -0
- package/lib/core/helpers/vaults.js +22 -8
- package/lib/core/helpers/web3.d.ts +152 -0
- package/lib/core/helpers/web3.js +183 -6
- 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 +6 -0
- package/lib/core/vault-metadata.js +6 -0
- package/lib/core/version-check.d.ts +52 -0
- package/lib/core/version-check.js +81 -0
- package/lib/evm/methods/crossChainVault.d.ts +90 -0
- package/lib/evm/methods/crossChainVault.js +186 -1
- 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 +11 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +19 -0
- package/lib/main.d.ts +288 -5
- package/lib/main.js +305 -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 +15 -0
- package/lib/modules/sub-accounts/fetcher.js +15 -0
- package/lib/modules/sub-accounts/main.d.ts +33 -0
- package/lib/modules/sub-accounts/main.js +38 -0
- package/lib/modules/sub-accounts/utils.d.ts +3 -0
- package/lib/modules/sub-accounts/utils.js +3 -0
- package/lib/modules/vaults/adapter.helpers.d.ts +18 -0
- package/lib/modules/vaults/adapter.helpers.js +34 -0
- package/lib/modules/vaults/fetcher.d.ts +20 -0
- package/lib/modules/vaults/fetcher.js +40 -3
- package/lib/modules/vaults/getters.d.ts +295 -0
- package/lib/modules/vaults/getters.js +552 -12
- 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 +379 -7
- package/lib/modules/vaults/read.actions.d.ts +168 -0
- 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 +47 -0
- 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 +70 -0
- package/lib/modules/vaults/utils.js +108 -5
- package/lib/modules/vaults/write.actions.d.ts +363 -3
- package/lib/modules/vaults/write.actions.js +364 -2
- package/lib/polyfills.js +2 -0
- package/lib/sdk.d.ts +23705 -0
- package/lib/services/coingecko/fetcher.d.ts +13 -0
- package/lib/services/coingecko/fetcher.js +17 -0
- package/lib/services/debank/fetcher.d.ts +14 -0
- package/lib/services/debank/fetcher.js +12 -0
- package/lib/services/debank/utils.js +17 -0
- package/lib/services/layerzero/deposits.d.ts +11 -0
- package/lib/services/layerzero/deposits.js +34 -11
- package/lib/services/layerzero/redeems.d.ts +10 -0
- 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 +7 -0
- package/lib/services/octavfi/fetcher.js +25 -0
- package/lib/services/octavfi/utils.d.ts +12 -0
- 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 +43 -2
- package/lib/services/swap-quotes/index.d.ts +71 -0
- package/lib/services/swap-quotes/index.js +25 -0
- package/lib/services/swap-quotes/paraswap.d.ts +17 -0
- package/lib/services/swap-quotes/paraswap.js +14 -0
- package/lib/types/pools.d.ts +3 -0
- package/lib/types/typed-contract.d.ts +64 -0
- package/lib/types/vaults.d.ts +139 -2
- package/lib/types/vaults.js +10 -0
- package/lib/types/web3.d.ts +8 -0
- package/lib/types/web3.js +1 -0
- package/lib/types/webserver.d.ts +45 -0
- package/package.json +6 -5
package/lib/main.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The main August SDK class.
|
|
4
|
+
*
|
|
5
|
+
* @module AugustSDK
|
|
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);
|
|
@@ -45,11 +50,34 @@ const core_1 = require("./core");
|
|
|
45
50
|
const vaults_1 = require("./modules/vaults");
|
|
46
51
|
const analytics_1 = require("./core/analytics");
|
|
47
52
|
const sub_accounts_1 = require("./modules/sub-accounts");
|
|
53
|
+
const api_1 = require("./modules/api");
|
|
54
|
+
/**
|
|
55
|
+
* Main SDK class for interacting with August Digital vaults and services.
|
|
56
|
+
* Provides unified access to EVM, Solana, Sui, and Stellar blockchain adapters.
|
|
57
|
+
*/
|
|
48
58
|
class AugustSDK extends core_1.AugustBase {
|
|
59
|
+
/**
|
|
60
|
+
* Initialize the August SDK with provider configuration.
|
|
61
|
+
* Automatically sets up EVM adapter and optionally initializes Solana if RPC URL is provided.
|
|
62
|
+
*/
|
|
49
63
|
constructor(baseConfig) {
|
|
50
64
|
super(baseConfig);
|
|
65
|
+
// @todo: change this later when august key is required
|
|
51
66
|
this.authorized = true;
|
|
67
|
+
// EVM adapter is always available
|
|
52
68
|
this.evm = new evm_1.default();
|
|
69
|
+
// @solana: handle solana service initialization
|
|
70
|
+
//
|
|
71
|
+
// Two accepted entry points, treated as exclusive sources so url+network
|
|
72
|
+
// can never come from different configs:
|
|
73
|
+
// 1) `baseConfig.solana = { rpcUrl, network }` — preferred. Both fields
|
|
74
|
+
// come from the same place; the caller controls the network.
|
|
75
|
+
// 2) `baseConfig.providers[-1] = rpcUrl` — legacy "Solana as another
|
|
76
|
+
// EVM chain" shape. Network is derived from the URL substring.
|
|
77
|
+
//
|
|
78
|
+
// Without one of these `this.solana` stays undefined and every Solana
|
|
79
|
+
// vault is silently dropped from getVaults / getVaultPositions (the
|
|
80
|
+
// filter in modules/vaults/main.ts gates on `!!this.solanaService`).
|
|
53
81
|
const solanaConfig = (() => {
|
|
54
82
|
if (baseConfig.solana?.rpcUrl) {
|
|
55
83
|
return {
|
|
@@ -76,24 +104,50 @@ class AugustSDK extends core_1.AugustBase {
|
|
|
76
104
|
this.stellar = new stellar_1.default();
|
|
77
105
|
this.vaults = new vaults_1.AugustVaults(baseConfig, this.solana, this.sui);
|
|
78
106
|
this.subaccounts = new sub_accounts_1.AugustSubAccounts(baseConfig);
|
|
107
|
+
this.api = new api_1.AugustApi();
|
|
108
|
+
// Instrument all SDK methods for analytics tracking
|
|
79
109
|
(0, analytics_1.instrumentClass)(this, () => this.activeNetwork?.chainId);
|
|
80
110
|
(0, analytics_1.instrumentClass)(this.evm, () => this.activeNetwork?.chainId);
|
|
81
111
|
(0, analytics_1.instrumentClass)(this.sui, () => this.activeNetwork?.chainId);
|
|
82
112
|
(0, analytics_1.instrumentClass)(this.stellar, () => core_1.SPECIAL_CHAINS.stellar?.chainId);
|
|
83
113
|
(0, analytics_1.instrumentClass)(this.vaults, () => this.activeNetwork?.chainId);
|
|
84
114
|
(0, analytics_1.instrumentClass)(this.subaccounts, () => this.activeNetwork?.chainId);
|
|
115
|
+
(0, analytics_1.instrumentClass)(this.api, () => this.activeNetwork?.chainId);
|
|
85
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Get the Sub-Accounts module instance.
|
|
119
|
+
*/
|
|
86
120
|
get subAccountsModule() {
|
|
87
121
|
return this.subaccounts;
|
|
88
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Get the Vaults module instance.
|
|
125
|
+
*/
|
|
89
126
|
get vaultsModule() {
|
|
90
127
|
return this.vaults;
|
|
91
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Get the backend API module instance ({@link AugustApi}) — read-only
|
|
131
|
+
* access to backend-computed data with no on-chain equivalent
|
|
132
|
+
* (unrealized-PnL series).
|
|
133
|
+
*/
|
|
134
|
+
get apiModule() {
|
|
135
|
+
return this.api;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Switch the active network for vault operations.
|
|
139
|
+
* Updates the SDK's active chain and RPC provider.
|
|
140
|
+
*/
|
|
92
141
|
switchNetwork(chainId) {
|
|
93
142
|
super.switchNetwork(chainId);
|
|
94
143
|
this.vaults.switchNetwork(chainId);
|
|
144
|
+
// Track network switch for analytics
|
|
95
145
|
(0, analytics_1.trackNetworkSwitch)(chainId);
|
|
96
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Set the active wallet address for tracking user-specific vault data.
|
|
149
|
+
* Updates monitoring headers with the wallet address.
|
|
150
|
+
*/
|
|
97
151
|
updateWallet(address) {
|
|
98
152
|
if (!address)
|
|
99
153
|
return;
|
|
@@ -102,12 +156,25 @@ class AugustSDK extends core_1.AugustBase {
|
|
|
102
156
|
}
|
|
103
157
|
this.vaults.updateWallet(address);
|
|
104
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Clear the active wallet address from the SDK state and monitoring headers.
|
|
161
|
+
*/
|
|
105
162
|
clearWallet() {
|
|
106
163
|
if (this.monitoring) {
|
|
107
164
|
this.monitoring['x-user-id'] = undefined;
|
|
108
165
|
}
|
|
109
166
|
this.vaults.clearWallet();
|
|
110
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Pricing and Market Data
|
|
170
|
+
*/
|
|
171
|
+
/**
|
|
172
|
+
* Get the current USD price of a token by symbol or contract address.
|
|
173
|
+
* Falls back to CoinGecko if primary price source fails.
|
|
174
|
+
*
|
|
175
|
+
* @param symbol - Token symbol or contract address
|
|
176
|
+
* @returns Current price in USD
|
|
177
|
+
*/
|
|
111
178
|
async getPrice(symbol) {
|
|
112
179
|
if (!this.authorized)
|
|
113
180
|
throw new Error('Not authorized.');
|
|
@@ -115,90 +182,314 @@ class AugustSDK extends core_1.AugustBase {
|
|
|
115
182
|
throw new Error(`Symbol input parameter is not defined.`);
|
|
116
183
|
return await (0, core_1.fetchTokenPrice)(symbol, null, this.keys?.coingecko);
|
|
117
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Vault Data and Operations
|
|
187
|
+
*/
|
|
188
|
+
/**
|
|
189
|
+
* Fetch all available vaults across configured networks.
|
|
190
|
+
* Optionally filter by chain IDs and include loan/allocation data.
|
|
191
|
+
* @param options - Configuration for filtering and enriching vault data
|
|
192
|
+
* @returns Array of vault objects with metadata and optional position data
|
|
193
|
+
*/
|
|
118
194
|
async getVaults(options) {
|
|
119
195
|
return await this.vaults.getVaults(options);
|
|
120
196
|
}
|
|
121
197
|
async getTotalDeposited(options) {
|
|
122
198
|
return await this.vaults.getTotalDeposited(options);
|
|
123
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Fetch all available vaults across configured networks.
|
|
202
|
+
* Optionally filter by chain IDs and include loan/allocation data.
|
|
203
|
+
* @param options - Configuration for filtering and enriching vault data
|
|
204
|
+
* @returns Array of vault objects with metadata and optional position data
|
|
205
|
+
*/
|
|
124
206
|
async vaultDeposit(signer, options) {
|
|
125
207
|
return await this.vaults.vaultDeposit(signer, options);
|
|
126
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Fetch detailed information for a specific vault.
|
|
211
|
+
* @param props - Vault address, chain ID, and optional enrichment options
|
|
212
|
+
* @returns Single vault object with full metadata
|
|
213
|
+
*/
|
|
127
214
|
async getVault(props) {
|
|
128
215
|
return await this.vaults.getVault(props);
|
|
129
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Get active loans deployed from a vault.
|
|
219
|
+
* @param props - Vault address and chain ID
|
|
220
|
+
* @returns Array of loan details including borrower, principal, APR
|
|
221
|
+
*/
|
|
130
222
|
async getVaultLoans(props) {
|
|
131
223
|
return await this.vaults.getVaultLoans(props);
|
|
132
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Get vault asset allocations across DeFi protocols, CeFi, and OTC positions.
|
|
227
|
+
* @param props - Vault address and chain ID
|
|
228
|
+
* @returns Detailed breakdown of vault allocations by category
|
|
229
|
+
*/
|
|
133
230
|
async getVaultAllocations(props) {
|
|
134
231
|
return await this.vaults.getVaultAllocations(props);
|
|
135
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Get current or historical APY for a vault.
|
|
235
|
+
*
|
|
236
|
+
* @deprecated use getVaultHistoricalTimeseries instead
|
|
237
|
+
*
|
|
238
|
+
* @param props - Vault address and optional historical lookback period
|
|
239
|
+
* @returns APY data including rewards breakdown
|
|
240
|
+
*/
|
|
136
241
|
async getVaultApy(props) {
|
|
137
242
|
return await this.vaults.getVaultApy(props);
|
|
138
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Get current or historical TVL for a vault.
|
|
246
|
+
* @param props - Vault address and optional historical parameters
|
|
247
|
+
* @returns TVL in vault's base asset units
|
|
248
|
+
*/
|
|
139
249
|
async getVaultTvl(props) {
|
|
140
250
|
return await this.vaults.getVaultTvl(props);
|
|
141
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* Get historical timeseries data for a vault.
|
|
254
|
+
* @param props - Vault address and optional number of days
|
|
255
|
+
* @returns Historical timeseries data with TVL, APY, PnL, share price, and other metrics
|
|
256
|
+
*/
|
|
142
257
|
async getVaultHistoricalTimeseries(props) {
|
|
143
258
|
return await this.vaults.getVaultHistoricalTimeseries(props);
|
|
144
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Get the timestamp when yield was last realized for a vault.
|
|
262
|
+
* @param props - Vault address and optional chain ID
|
|
263
|
+
* @returns Timestamp (Unix timestamp in seconds) when yield was last realized
|
|
264
|
+
*/
|
|
145
265
|
async getYieldLastRealizedOn(props) {
|
|
146
266
|
return await this.vaults.getYieldLastRealizedOn(props);
|
|
147
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Get redemption requests that are ready to be claimed.
|
|
270
|
+
* @param props - Vault address, chain ID, and optional wallet filter
|
|
271
|
+
* @returns Array of available redemption requests with amounts and timestamps
|
|
272
|
+
*/
|
|
148
273
|
async getVaultAvailableRedemptions(props) {
|
|
149
274
|
return await this.vaults.getVaultAvailableRedemptions(props);
|
|
150
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Get historical redemption requests for a vault (settled, cancelled,
|
|
278
|
+
* pending-but-out-of-window), optionally filtered to one wallet.
|
|
279
|
+
*
|
|
280
|
+
* @param props - Vault address, chain ID, optional wallet, and an
|
|
281
|
+
* optional `lookbackBlocks` for how far back to scan.
|
|
282
|
+
* @returns Historical redemption records, newest first.
|
|
283
|
+
*/
|
|
151
284
|
async getVaultRedemptionHistory(props) {
|
|
152
285
|
return await this.vaults.getVaultRedemptionHistory(props);
|
|
153
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* Get user positions across vaults including shares and claimable redemptions.
|
|
289
|
+
* Supports both EVM and Solana vaults.
|
|
290
|
+
* @param props - Wallet address, chain ID, and optional vault filter
|
|
291
|
+
* @returns Array of positions with balances and pending redemptions
|
|
292
|
+
*/
|
|
154
293
|
async getVaultPositions(props) {
|
|
155
294
|
return await this.vaults.getVaultPositions(props);
|
|
156
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* Get user's historical vault interactions including deposits and withdrawals.
|
|
298
|
+
* @param props - Wallet address and optional vault/chain filters
|
|
299
|
+
* @returns Array of historical transactions with amounts and timestamps
|
|
300
|
+
*/
|
|
157
301
|
async getVaultUserHistory(props) {
|
|
158
302
|
return await this.vaults.getUserHistory(props);
|
|
159
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Get user's vault share transfer history from subgraph.
|
|
306
|
+
* @param props - Wallet address and optional vault/chain filters
|
|
307
|
+
* @returns Array of transfer events
|
|
308
|
+
*/
|
|
160
309
|
async getVaultUserTransfers(props) {
|
|
161
310
|
return await this.vaults.getUserTransfers(props);
|
|
162
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Get lifetime PnL for a user in a specific vault.
|
|
314
|
+
* Calculates realized and unrealized PnL based on deposit/withdrawal history and current position.
|
|
315
|
+
* @param props - Vault address, wallet address, and optional chain ID
|
|
316
|
+
* @returns Lifetime PnL data including realized and unrealized PnL in both native token and USD
|
|
317
|
+
*/
|
|
163
318
|
async getVaultUserLifetimePnl(props) {
|
|
164
319
|
return await this.vaults.getVaultUserLifetimePnl(props);
|
|
165
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Get PnL for a vault (vault-level, not user-specific).
|
|
323
|
+
* Returns the vault's overall profit and loss across all users.
|
|
324
|
+
* @param props - Vault address and optional chain ID
|
|
325
|
+
* @returns Vault PnL in USD and notional value
|
|
326
|
+
*/
|
|
166
327
|
async getVaultPnl(props) {
|
|
167
328
|
return await this.vaults.getVaultPnl(props);
|
|
168
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* Get user's staking positions for vault receipt tokens.
|
|
332
|
+
* @param props - Wallet address and optional chain ID
|
|
333
|
+
* @returns Array of staking positions with rewards
|
|
334
|
+
*/
|
|
169
335
|
async getVaultStakingPositions(props) {
|
|
170
336
|
return await this.vaults.getStakingPositions(props.wallet, props.chainId);
|
|
171
337
|
}
|
|
338
|
+
/**
|
|
339
|
+
* Get the borrower's health factor by vault.
|
|
340
|
+
*
|
|
341
|
+
* Pass `vault` whenever the caller knows which pool it cares about — it
|
|
342
|
+
* skips the all-vaults cross-chain fanout and only reads the loans for
|
|
343
|
+
* that one pool. The response map is keyed by **lowercased** vault
|
|
344
|
+
* address; look entries up with `address.toLowerCase()`.
|
|
345
|
+
*
|
|
346
|
+
* @param props.chainId Optional chain to scope the read to.
|
|
347
|
+
* @param props.vault Optional vault address. When provided alongside
|
|
348
|
+
* `chainId`, only that vault's borrower-health-factor data is fetched.
|
|
349
|
+
* @returns Object containing the borrower's health factor by vault.
|
|
350
|
+
*/
|
|
172
351
|
async getVaultBorrowerHealthFactor(props) {
|
|
173
352
|
return await this.vaults.getVaultBorrowerHealthFactor(props?.chainId, props?.vault);
|
|
174
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Get user points from the backend API.
|
|
356
|
+
* This fetches processed points data directly from the backend,
|
|
357
|
+
* removing the need for client-side points calculation.
|
|
358
|
+
* @param userAddress - User wallet address
|
|
359
|
+
* @returns Points data from the backend API
|
|
360
|
+
*/
|
|
175
361
|
async getUserPoints(userAddress) {
|
|
176
362
|
return await this.vaults.getUserPoints(userAddress);
|
|
177
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Register a user for the points program, authenticated by a wallet signature.
|
|
366
|
+
*
|
|
367
|
+
* The caller produces a personal_sign signature over a canonical message
|
|
368
|
+
* containing the user address, referrer (or `"none"`), chain, nonce, and
|
|
369
|
+
* expiry — see `AugustVaults.registerUserForPoints` for the exact template.
|
|
370
|
+
*
|
|
371
|
+
* @param userAddress - EVM wallet address being registered.
|
|
372
|
+
* @param referrerAddress - Optional EVM referrer address.
|
|
373
|
+
* @param chainId - Chain on which the wallet signed; powers the EIP-1271
|
|
374
|
+
* fallback for smart-contract wallets and pins the signature cross-chain.
|
|
375
|
+
* @param signature - 0x-prefixed personal_sign signature over the canonical message.
|
|
376
|
+
* @param nonce - Single-use random string (8–128 chars).
|
|
377
|
+
* @param expiry - Unix seconds; must be in the future, within the backend's TTL.
|
|
378
|
+
* @returns Raw `Response` from the backend.
|
|
379
|
+
*/
|
|
178
380
|
async registerUserForPoints(userAddress, referrerAddress, chainId, signature, nonce, expiry) {
|
|
179
381
|
return await this.vaults.registerUserForPoints(userAddress, referrerAddress, chainId, signature, nonce, expiry);
|
|
180
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* Fetch the points leaderboard data.
|
|
385
|
+
* @param params - Optional parameters for pagination and sorting
|
|
386
|
+
* @returns Leaderboard response data
|
|
387
|
+
*/
|
|
181
388
|
async fetchPointsLeaderboard(params) {
|
|
182
389
|
return await this.vaults.fetchPointsLeaderboard(params);
|
|
183
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* Fetch the historical unrealized-PnL series for a vault, newest first.
|
|
393
|
+
* Delegates to {@link AugustApi.getVaultUnrealizedPnlHistory} — see it for
|
|
394
|
+
* parameter semantics and thrown errors.
|
|
395
|
+
*/
|
|
396
|
+
async getVaultUnrealizedPnlHistory(params) {
|
|
397
|
+
return await this.api.getVaultUnrealizedPnlHistory(params);
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Fetch the latest unrealized-PnL snapshot for every tracked vault.
|
|
401
|
+
* Delegates to {@link AugustApi.getLatestUnrealizedPnl} — see it for
|
|
402
|
+
* return shape and thrown errors.
|
|
403
|
+
*/
|
|
404
|
+
async getLatestUnrealizedPnl() {
|
|
405
|
+
return await this.api.getLatestUnrealizedPnl();
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Get annualized APY metrics for a vault.
|
|
409
|
+
*
|
|
410
|
+
* Supported Vaults: cUSDO, tETH, wstETH, rsETH
|
|
411
|
+
*
|
|
412
|
+
* @deprecated The `hgETH30dLiquidAPY` and `hgETH7dLiquidAPY` response fields are deprecated.
|
|
413
|
+
* These fields will be removed on 2026-01-01.
|
|
414
|
+
* Use `liquidAPY30Day` and `liquidAPY7Day` fields instead.
|
|
415
|
+
*
|
|
416
|
+
* @param props - Vault address
|
|
417
|
+
* @returns Annualized APY data including liquidity APY
|
|
418
|
+
*/
|
|
184
419
|
async getVaultAnnualizedApy(props) {
|
|
185
420
|
return await this.vaults.getVaultAnnualizedApy(props.vault);
|
|
186
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Get summary data for a vault (name, type, chain, recent returns).
|
|
424
|
+
* @param props - Vault address
|
|
425
|
+
* @returns Vault summary data
|
|
426
|
+
*/
|
|
187
427
|
async getVaultSummary(props) {
|
|
188
428
|
return await this.vaults.getVaultSummary(props.vault);
|
|
189
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* Get withdrawal summary and pending queue for a vault.
|
|
432
|
+
* @param props - Vault address and optional chain ID
|
|
433
|
+
* @returns Withdrawal summary and pending queue
|
|
434
|
+
*/
|
|
190
435
|
async getVaultWithdrawals(props) {
|
|
191
436
|
return await this.vaults.getVaultWithdrawals(props.vault, props.chainId);
|
|
192
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* Preview the amount of assets that would be received for redeeming shares (queued redemption).
|
|
440
|
+
* @param props - Vault contract address, shares amount, and optional chain ID
|
|
441
|
+
* @returns The amount of assets as {@link INormalizedNumber}
|
|
442
|
+
*/
|
|
193
443
|
async previewRedemption(props) {
|
|
194
444
|
return await this.vaults.previewRedemption(props);
|
|
195
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
* Query LayerZero USDC deposits from the august-layerzero subgraphs.
|
|
448
|
+
* Returns all deposits or filters by sender wallet address if provided.
|
|
449
|
+
*
|
|
450
|
+
* **Important Notes:**
|
|
451
|
+
* - Only deposit transactions are tracked (not withdrawals or other operations)
|
|
452
|
+
* - Sender and recipient addresses are stored in bytes32 format in the subgraph
|
|
453
|
+
* - Timestamps are available from the subgraph
|
|
454
|
+
*
|
|
455
|
+
* **Supported Vaults:**
|
|
456
|
+
* - `upusdc`: 0x80E1048eDE66ec4c364b4F22C8768fc657FF6A42
|
|
457
|
+
* - `coreusdc`: 0xE9B725010A9E419412ed67d0fA5f3A5f40159D32
|
|
458
|
+
* - `earnausd`: 0x36eDbF0C834591BFdfCaC0Ef9605528c75c406aA
|
|
459
|
+
*
|
|
460
|
+
* @param props - Receipt token type ('upusdc', 'coreusdc', or 'earnausd') and optional wallet address to filter by sender
|
|
461
|
+
* @returns Array of deposit events with the following structure:
|
|
462
|
+
* - `assetAmt`: Amount of assets deposited (as string)
|
|
463
|
+
* - `shareAmt`: Amount of shares received (as string)
|
|
464
|
+
* - `sender`: Sender address in bytes32 format
|
|
465
|
+
* - `recipient`: Recipient address in bytes32 format
|
|
466
|
+
* - `dstEid`: Destination endpoint ID (LayerZero chain identifier)
|
|
467
|
+
* - `transactionHash_`: Transaction hash
|
|
468
|
+
*
|
|
469
|
+
* @throws Error if receipt token is invalid or GraphQL request fails
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* ```typescript
|
|
473
|
+
* // Get all coreUSDC deposits
|
|
474
|
+
* const allDeposits = await sdk.getLayerZeroDeposits({
|
|
475
|
+
* receiptToken: 'coreusdc'
|
|
476
|
+
* });
|
|
477
|
+
*
|
|
478
|
+
* // Get deposits for a specific wallet
|
|
479
|
+
* const userDeposits = await sdk.getLayerZeroDeposits({
|
|
480
|
+
* receiptToken: 'upusdc',
|
|
481
|
+
* wallet: '0xb0280B58F541131b29D1B33319CD440a99eA0305'
|
|
482
|
+
* });
|
|
483
|
+
* ```
|
|
484
|
+
*/
|
|
196
485
|
async getLayerZeroDeposits(props) {
|
|
486
|
+
// Runtime validation for receipt token
|
|
197
487
|
const validTokens = ['upusdc', 'coreusdc', 'earnausd'];
|
|
198
488
|
if (!validTokens.includes(props.receiptToken)) {
|
|
199
489
|
throw new Error(`Invalid receiptToken: ${props.receiptToken}. Must be 'upusdc', 'coreusdc', or 'earnausd'.`);
|
|
200
490
|
}
|
|
201
491
|
const { queryLayerZeroDeposits } = await Promise.resolve().then(() => __importStar(require('./services/layerzero/deposits')));
|
|
492
|
+
// Map receipt token to vault key
|
|
202
493
|
const vaultKeyMap = {
|
|
203
494
|
upusdc: 'upUSDC',
|
|
204
495
|
coreusdc: 'coreUSDC',
|
|
@@ -207,6 +498,20 @@ class AugustSDK extends core_1.AugustBase {
|
|
|
207
498
|
const vaultKey = vaultKeyMap[props.receiptToken];
|
|
208
499
|
return await queryLayerZeroDeposits(vaultKey, props.wallet);
|
|
209
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Get LayerZero redeems for earnAUSD vault
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```typescript
|
|
506
|
+
* // Get all earnAUSD redeems
|
|
507
|
+
* const allRedeems = await sdk.getLayerZeroRedeems();
|
|
508
|
+
*
|
|
509
|
+
* // Get redeems for a specific wallet
|
|
510
|
+
* const userRedeems = await sdk.getLayerZeroRedeems({
|
|
511
|
+
* wallet: '0x2de1DCB8EaAd40fAd327fa3eE3F48774b8e20649'
|
|
512
|
+
* });
|
|
513
|
+
* ```
|
|
514
|
+
*/
|
|
210
515
|
async getLayerZeroRedeems(props) {
|
|
211
516
|
const { queryLayerZeroRedeems } = await Promise.resolve().then(() => __importStar(require('./services/layerzero/redeems')));
|
|
212
517
|
return await queryLayerZeroRedeems(props?.wallet);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AugustApi } from './main';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AugustApi = void 0;
|
|
4
|
+
var main_1 = require("./main");
|
|
5
|
+
Object.defineProperty(exports, "AugustApi", { enumerable: true, get: function () { return main_1.AugustApi; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { IUnrealizedPnlSnapshot } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Read-only client for August backend REST endpoints that have no on-chain
|
|
4
|
+
* equivalent — currently the unrealized-PnL series the backend computes
|
|
5
|
+
* from periodic vault snapshots.
|
|
6
|
+
*
|
|
7
|
+
* Every method makes exactly one HTTPS request to the public
|
|
8
|
+
* (unauthenticated) August API and zero RPC calls. Responses are not cached
|
|
9
|
+
* by the SDK: this is time-sensitive PnL state where staleness is worse
|
|
10
|
+
* than request latency.
|
|
11
|
+
*
|
|
12
|
+
* Accessible as `apiModule` on the SDK instance; the same methods are also
|
|
13
|
+
* exposed directly on the SDK class.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AugustApi {
|
|
16
|
+
/**
|
|
17
|
+
* Fetch the historical unrealized-PnL series for a vault, newest first,
|
|
18
|
+
* as computed by the August backend from periodic vault snapshots.
|
|
19
|
+
*
|
|
20
|
+
* Makes one HTTPS request to the public August API; no RPC calls.
|
|
21
|
+
*
|
|
22
|
+
* @param params.vault Vault address (EVM `0x…`, Solana, or Stellar).
|
|
23
|
+
* @param params.limit Maximum number of snapshots to return (1–1000). Backend default applies when omitted.
|
|
24
|
+
* @returns Array of {@link IUnrealizedPnlSnapshot}; empty when the backend has no history for the vault.
|
|
25
|
+
* @throws AugustValidationError When `vault` is not a valid address or `limit` is out of range.
|
|
26
|
+
* @throws AugustServerError When the API responds with a 5xx, or returns a body that is not a snapshot array.
|
|
27
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
28
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
29
|
+
* @example
|
|
30
|
+
* const series = await sdk.getVaultUnrealizedPnlHistory({ vault: '0x36eDbF0C834591BFdfCaC0Ef9605528c75c406aA', limit: 30 });
|
|
31
|
+
* console.log(series[0]?.unrealizedPnlInAsset);
|
|
32
|
+
*/
|
|
33
|
+
getVaultUnrealizedPnlHistory(params: {
|
|
34
|
+
vault: string;
|
|
35
|
+
limit?: number;
|
|
36
|
+
}): Promise<IUnrealizedPnlSnapshot[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Fetch the latest unrealized-PnL snapshot for every vault the backend
|
|
39
|
+
* tracks — one entry per vault.
|
|
40
|
+
*
|
|
41
|
+
* Makes one HTTPS request to the public August API; no RPC calls.
|
|
42
|
+
*
|
|
43
|
+
* @returns Array of {@link IUnrealizedPnlSnapshot}, one per tracked vault.
|
|
44
|
+
* @throws AugustServerError When the API responds with a 5xx, or returns a body that is not a snapshot array.
|
|
45
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
46
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
47
|
+
* @example
|
|
48
|
+
* const all = await sdk.getLatestUnrealizedPnl();
|
|
49
|
+
* const losing = all.filter((s) => s.unrealizedPnl < 0);
|
|
50
|
+
*/
|
|
51
|
+
getLatestUnrealizedPnl(): Promise<IUnrealizedPnlSnapshot[]>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AugustApi = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const core_1 = require("../../core/constants/core");
|
|
6
|
+
const errors_1 = require("../../core/errors");
|
|
7
|
+
const fetcher_1 = require("../../core/fetcher");
|
|
8
|
+
const chain_address_1 = require("../../core/helpers/chain-address");
|
|
9
|
+
function toUnrealizedPnlSnapshot(raw) {
|
|
10
|
+
return {
|
|
11
|
+
timestamp: raw.timestamp,
|
|
12
|
+
vaultName: raw.vault_name,
|
|
13
|
+
vaultAddress: raw.vault_address,
|
|
14
|
+
strategistName: raw.strategist_name ?? null,
|
|
15
|
+
referenceAsset: raw.reference_asset,
|
|
16
|
+
assetPrice: raw.asset_price,
|
|
17
|
+
tvlOnVault: raw.tvl_on_vault,
|
|
18
|
+
currentRedeemRatio: raw.current_redeem_ratio,
|
|
19
|
+
actualTvl: raw.actual_tvl,
|
|
20
|
+
adjustedRedeemRatio: raw.adjusted_redeem_ratio,
|
|
21
|
+
unrealizedPnl: raw.unrealized_pnl,
|
|
22
|
+
unrealizedPnlInAsset: raw.unrealized_pnl_in_asset,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function assertVaultAddress(vault, method) {
|
|
26
|
+
const valid = typeof vault === 'string' &&
|
|
27
|
+
vault.length > 0 &&
|
|
28
|
+
((0, ethers_1.isAddress)(vault) || (0, chain_address_1.isSolanaAddress)(vault) || (0, chain_address_1.isStellarAddress)(vault));
|
|
29
|
+
if (!valid) {
|
|
30
|
+
throw new errors_1.AugustValidationError('INVALID_ADDRESS', `${method}: "${vault}" is not a valid vault address — pass the vault's EVM (0x…), Solana, or Stellar address.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const SNAPSHOT_STRING_FIELDS = [
|
|
34
|
+
'timestamp',
|
|
35
|
+
'vault_name',
|
|
36
|
+
'vault_address',
|
|
37
|
+
'reference_asset',
|
|
38
|
+
];
|
|
39
|
+
const SNAPSHOT_NUMBER_FIELDS = [
|
|
40
|
+
'asset_price',
|
|
41
|
+
'tvl_on_vault',
|
|
42
|
+
'current_redeem_ratio',
|
|
43
|
+
'actual_tvl',
|
|
44
|
+
'adjusted_redeem_ratio',
|
|
45
|
+
'unrealized_pnl',
|
|
46
|
+
'unrealized_pnl_in_asset',
|
|
47
|
+
];
|
|
48
|
+
function isRawSnapshot(item) {
|
|
49
|
+
if (!item || typeof item !== 'object')
|
|
50
|
+
return false;
|
|
51
|
+
const record = item;
|
|
52
|
+
return (SNAPSHOT_STRING_FIELDS.every((field) => typeof record[field] === 'string') &&
|
|
53
|
+
SNAPSHOT_NUMBER_FIELDS.every((field) => typeof record[field] === 'number'));
|
|
54
|
+
}
|
|
55
|
+
function assertSnapshotArray(data, method) {
|
|
56
|
+
const valid = Array.isArray(data) && data.every(isRawSnapshot);
|
|
57
|
+
if (!valid) {
|
|
58
|
+
throw new errors_1.AugustServerError(200, `${method}: unexpected response shape from the August API — expected an array of PnL snapshots. The backend contract may have changed; refresh packages/sdk/api-spec and update the SDK.`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Read-only client for August backend REST endpoints that have no on-chain
|
|
63
|
+
* equivalent — currently the unrealized-PnL series the backend computes
|
|
64
|
+
* from periodic vault snapshots.
|
|
65
|
+
*
|
|
66
|
+
* Every method makes exactly one HTTPS request to the public
|
|
67
|
+
* (unauthenticated) August API and zero RPC calls. Responses are not cached
|
|
68
|
+
* by the SDK: this is time-sensitive PnL state where staleness is worse
|
|
69
|
+
* than request latency.
|
|
70
|
+
*
|
|
71
|
+
* Accessible as `apiModule` on the SDK instance; the same methods are also
|
|
72
|
+
* exposed directly on the SDK class.
|
|
73
|
+
*/
|
|
74
|
+
class AugustApi {
|
|
75
|
+
/**
|
|
76
|
+
* Fetch the historical unrealized-PnL series for a vault, newest first,
|
|
77
|
+
* as computed by the August backend from periodic vault snapshots.
|
|
78
|
+
*
|
|
79
|
+
* Makes one HTTPS request to the public August API; no RPC calls.
|
|
80
|
+
*
|
|
81
|
+
* @param params.vault Vault address (EVM `0x…`, Solana, or Stellar).
|
|
82
|
+
* @param params.limit Maximum number of snapshots to return (1–1000). Backend default applies when omitted.
|
|
83
|
+
* @returns Array of {@link IUnrealizedPnlSnapshot}; empty when the backend has no history for the vault.
|
|
84
|
+
* @throws AugustValidationError When `vault` is not a valid address or `limit` is out of range.
|
|
85
|
+
* @throws AugustServerError When the API responds with a 5xx, or returns a body that is not a snapshot array.
|
|
86
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
87
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
88
|
+
* @example
|
|
89
|
+
* const series = await sdk.getVaultUnrealizedPnlHistory({ vault: '0x36eDbF0C834591BFdfCaC0Ef9605528c75c406aA', limit: 30 });
|
|
90
|
+
* console.log(series[0]?.unrealizedPnlInAsset);
|
|
91
|
+
*/
|
|
92
|
+
async getVaultUnrealizedPnlHistory(params) {
|
|
93
|
+
const method = 'getVaultUnrealizedPnlHistory';
|
|
94
|
+
assertVaultAddress(params.vault, method);
|
|
95
|
+
if (params.limit !== undefined &&
|
|
96
|
+
(!Number.isInteger(params.limit) ||
|
|
97
|
+
params.limit < 1 ||
|
|
98
|
+
params.limit > 1000)) {
|
|
99
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: limit must be an integer between 1 and 1000, got ${params.limit}.`);
|
|
100
|
+
}
|
|
101
|
+
const endpoint = core_1.WEBSERVER_ENDPOINTS.public.pnl.unrealizedHistory(params.vault, params.limit);
|
|
102
|
+
const response = await (0, fetcher_1.fetchAugustPublic)(endpoint);
|
|
103
|
+
const data = await response.json();
|
|
104
|
+
assertSnapshotArray(data, method);
|
|
105
|
+
return data.map(toUnrealizedPnlSnapshot);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Fetch the latest unrealized-PnL snapshot for every vault the backend
|
|
109
|
+
* tracks — one entry per vault.
|
|
110
|
+
*
|
|
111
|
+
* Makes one HTTPS request to the public August API; no RPC calls.
|
|
112
|
+
*
|
|
113
|
+
* @returns Array of {@link IUnrealizedPnlSnapshot}, one per tracked vault.
|
|
114
|
+
* @throws AugustServerError When the API responds with a 5xx, or returns a body that is not a snapshot array.
|
|
115
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
116
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
117
|
+
* @example
|
|
118
|
+
* const all = await sdk.getLatestUnrealizedPnl();
|
|
119
|
+
* const losing = all.filter((s) => s.unrealizedPnl < 0);
|
|
120
|
+
*/
|
|
121
|
+
async getLatestUnrealizedPnl() {
|
|
122
|
+
const method = 'getLatestUnrealizedPnl';
|
|
123
|
+
const response = await (0, fetcher_1.fetchAugustPublic)(core_1.WEBSERVER_ENDPOINTS.public.pnl.unrealizedLatest);
|
|
124
|
+
const data = await response.json();
|
|
125
|
+
assertSnapshotArray(data, method);
|
|
126
|
+
return data.map(toUnrealizedPnlSnapshot);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.AugustApi = AugustApi;
|
|
130
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { IFetchAugustOptions } from '../../core';
|
|
2
2
|
import { IAddress, IOTCPosition, IWSSubaccountCefi, IWSSubAccountHealthFactor, IWSSubaccountLoan, IWSSubaccountSummary } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Fetch subaccount health factor for a given subaccount address
|
|
5
|
+
*/
|
|
3
6
|
export declare const fetchSubaccountHeathFactor: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubAccountHealthFactor>;
|
|
7
|
+
/**
|
|
8
|
+
* Fetch subaccount loans details
|
|
9
|
+
*/
|
|
4
10
|
export declare const fetchSubaccountLoans: (payload: {
|
|
5
11
|
address: IAddress;
|
|
6
12
|
side?: "BOTH" | "BORROWER" | "LENDER";
|
|
7
13
|
active?: boolean;
|
|
8
14
|
}, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountLoan[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch the subaccount CeFi positions
|
|
17
|
+
*/
|
|
9
18
|
export declare const fetchSubaccountCefiPositions: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountCefi[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch the subaccount OTC positions
|
|
21
|
+
*/
|
|
10
22
|
export declare const fetchSubaccountOtcPositions: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IOTCPosition[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Fetch the subaccount summary view
|
|
25
|
+
*/
|
|
11
26
|
export declare const fetchSubaccountSummary: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountSummary>;
|