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