upshift-finance 1.0.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/LICENSE +21 -0
- package/README.md +349 -0
- package/lib/abis/AddressResolver.d.ts +28 -0
- package/lib/abis/AddressResolver.js +23 -0
- package/lib/abis/ChainlinkV3.d.ts +87 -0
- package/lib/abis/ChainlinkV3.js +117 -0
- package/lib/abis/ERC20.d.ts +168 -0
- package/lib/abis/ERC20.js +226 -0
- package/lib/abis/ERC20_Bytes32.d.ts +139 -0
- package/lib/abis/ERC20_Bytes32.js +196 -0
- package/lib/abis/ERC4626.d.ts +364 -0
- package/lib/abis/ERC4626.js +507 -0
- package/lib/abis/ERC721.d.ts +231 -0
- package/lib/abis/ERC721.js +321 -0
- package/lib/abis/FeeOracle.d.ts +120 -0
- package/lib/abis/FeeOracle.js +162 -0
- package/lib/abis/LendingPool.d.ts +1393 -0
- package/lib/abis/LendingPool.js +1807 -0
- package/lib/abis/LendingPoolV2.d.ts +1413 -0
- package/lib/abis/LendingPoolV2.js +1833 -0
- package/lib/abis/LendingPoolV3.d.ts +1677 -0
- package/lib/abis/LendingPoolV3.js +1160 -0
- package/lib/abis/Loan.d.ts +837 -0
- package/lib/abis/Loan.js +1080 -0
- package/lib/abis/MultiAssetNativeDepositWrapper.d.ts +137 -0
- package/lib/abis/MultiAssetNativeDepositWrapper.js +125 -0
- package/lib/abis/Multicall3.d.ts +30 -0
- package/lib/abis/Multicall3.js +97 -0
- package/lib/abis/OFT.d.ts +116 -0
- package/lib/abis/OFT.js +85 -0
- package/lib/abis/PoolAdapter.d.ts +36 -0
- package/lib/abis/PoolAdapter.js +51 -0
- package/lib/abis/RewardDistributor.d.ts +267 -0
- package/lib/abis/RewardDistributor.js +352 -0
- package/lib/abis/RwaRedeemSubaccount.d.ts +747 -0
- package/lib/abis/RwaRedeemSubaccount.js +548 -0
- package/lib/abis/SmartAccount.d.ts +17 -0
- package/lib/abis/SmartAccount.js +19 -0
- package/lib/abis/SwapRouter.d.ts +1043 -0
- package/lib/abis/SwapRouter.js +740 -0
- package/lib/abis/TextResolver.d.ts +16 -0
- package/lib/abis/TextResolver.js +16 -0
- package/lib/abis/TokenizedVaultV2.d.ts +1364 -0
- package/lib/abis/TokenizedVaultV2.js +1041 -0
- package/lib/abis/TokenizedVaultV2DepositWithPermit.d.ts +1456 -0
- package/lib/abis/TokenizedVaultV2DepositWithPermit.js +1878 -0
- package/lib/abis/TokenizedVaultV2Receipt.d.ts +1568 -0
- package/lib/abis/TokenizedVaultV2Receipt.js +1061 -0
- package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.d.ts +454 -0
- package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js +327 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAllocation.d.ts +1466 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js +1092 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAssets.d.ts +274 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAssets.js +167 -0
- package/lib/abis/UniversalResolverResolve.d.ts +69 -0
- package/lib/abis/UniversalResolverResolve.js +35 -0
- package/lib/abis/UniversalSignatureValidator.d.ts +17 -0
- package/lib/abis/UniversalSignatureValidator.js +30 -0
- package/lib/abis/WrapperAdapter.d.ts +71 -0
- package/lib/abis/WrapperAdapter.js +77 -0
- package/lib/abis/index.d.ts +34 -0
- package/lib/abis/index.js +51 -0
- package/lib/adapters/evm/getters.d.ts +19 -0
- package/lib/adapters/evm/getters.js +209 -0
- package/lib/adapters/evm/index.d.ts +353 -0
- package/lib/adapters/evm/index.js +434 -0
- package/lib/adapters/evm/utils.d.ts +8 -0
- package/lib/adapters/evm/utils.js +51 -0
- package/lib/adapters/solana/constants.d.ts +33 -0
- package/lib/adapters/solana/constants.js +52 -0
- package/lib/adapters/solana/getters.d.ts +11 -0
- package/lib/adapters/solana/getters.js +165 -0
- package/lib/adapters/solana/idl/vault-idl.d.ts +272 -0
- package/lib/adapters/solana/idl/vault-idl.js +1084 -0
- package/lib/adapters/solana/index.d.ts +233 -0
- package/lib/adapters/solana/index.js +291 -0
- package/lib/adapters/solana/types.d.ts +67 -0
- package/lib/adapters/solana/types.js +3 -0
- package/lib/adapters/solana/utils.d.ts +141 -0
- package/lib/adapters/solana/utils.js +595 -0
- package/lib/adapters/solana/vault.actions.d.ts +57 -0
- package/lib/adapters/solana/vault.actions.js +379 -0
- package/lib/adapters/stellar/actions.d.ts +28 -0
- package/lib/adapters/stellar/actions.js +77 -0
- package/lib/adapters/stellar/constants.d.ts +43 -0
- package/lib/adapters/stellar/constants.js +53 -0
- package/lib/adapters/stellar/getters.d.ts +68 -0
- package/lib/adapters/stellar/getters.js +290 -0
- package/lib/adapters/stellar/index.d.ts +114 -0
- package/lib/adapters/stellar/index.js +175 -0
- package/lib/adapters/stellar/soroban.d.ts +123 -0
- package/lib/adapters/stellar/soroban.js +613 -0
- package/lib/adapters/stellar/submit.d.ts +34 -0
- package/lib/adapters/stellar/submit.js +149 -0
- package/lib/adapters/stellar/types.d.ts +58 -0
- package/lib/adapters/stellar/types.js +6 -0
- package/lib/adapters/stellar/utils.d.ts +24 -0
- package/lib/adapters/stellar/utils.js +34 -0
- package/lib/adapters/sui/constants.d.ts +14 -0
- package/lib/adapters/sui/constants.js +29 -0
- package/lib/adapters/sui/getters.d.ts +9 -0
- package/lib/adapters/sui/getters.js +60 -0
- package/lib/adapters/sui/index.d.ts +45 -0
- package/lib/adapters/sui/index.js +101 -0
- package/lib/adapters/sui/transformer.d.ts +10 -0
- package/lib/adapters/sui/transformer.js +107 -0
- package/lib/adapters/sui/types.d.ts +66 -0
- package/lib/adapters/sui/types.js +3 -0
- package/lib/adapters/sui/utils.d.ts +10 -0
- package/lib/adapters/sui/utils.js +29 -0
- package/lib/core/analytics/chain-name.d.ts +9 -0
- package/lib/core/analytics/chain-name.js +34 -0
- package/lib/core/analytics/constants.d.ts +5 -0
- package/lib/core/analytics/constants.js +9 -0
- package/lib/core/analytics/env.d.ts +29 -0
- package/lib/core/analytics/env.js +59 -0
- package/lib/core/analytics/index.d.ts +36 -0
- package/lib/core/analytics/index.js +79 -0
- package/lib/core/analytics/instrumentation.d.ts +29 -0
- package/lib/core/analytics/instrumentation.js +277 -0
- package/lib/core/analytics/method-taxonomy.d.ts +19 -0
- package/lib/core/analytics/method-taxonomy.js +128 -0
- package/lib/core/analytics/metrics.d.ts +33 -0
- package/lib/core/analytics/metrics.js +116 -0
- package/lib/core/analytics/sanitize.d.ts +44 -0
- package/lib/core/analytics/sanitize.js +260 -0
- package/lib/core/analytics/sentry-runtime.d.ts +15 -0
- package/lib/core/analytics/sentry-runtime.js +97 -0
- package/lib/core/analytics/sentry.d.ts +67 -0
- package/lib/core/analytics/sentry.js +613 -0
- package/lib/core/analytics/types.d.ts +48 -0
- package/lib/core/analytics/types.js +3 -0
- package/lib/core/analytics/user-identity.d.ts +41 -0
- package/lib/core/analytics/user-identity.js +141 -0
- package/lib/core/analytics/version.d.ts +6 -0
- package/lib/core/analytics/version.js +10 -0
- package/lib/core/attribution.d.ts +111 -0
- package/lib/core/attribution.js +142 -0
- package/lib/core/auth/index.d.ts +1 -0
- package/lib/core/auth/index.js +18 -0
- package/lib/core/auth/verify.d.ts +2 -0
- package/lib/core/auth/verify.js +31 -0
- package/lib/core/base.class.d.ts +152 -0
- package/lib/core/base.class.js +172 -0
- package/lib/core/cache.d.ts +9 -0
- package/lib/core/cache.js +31 -0
- package/lib/core/constants/adapters.d.ts +103 -0
- package/lib/core/constants/adapters.js +180 -0
- package/lib/core/constants/core.d.ts +133 -0
- package/lib/core/constants/core.js +209 -0
- package/lib/core/constants/swap-router.d.ts +150 -0
- package/lib/core/constants/swap-router.js +169 -0
- package/lib/core/constants/vaults.d.ts +93 -0
- package/lib/core/constants/vaults.js +273 -0
- package/lib/core/constants/web3.d.ts +91 -0
- package/lib/core/constants/web3.js +229 -0
- package/lib/core/errors/index.d.ts +114 -0
- package/lib/core/errors/index.js +183 -0
- package/lib/core/fetcher.d.ts +198 -0
- package/lib/core/fetcher.js +903 -0
- package/lib/core/helpers/adapters.d.ts +13 -0
- package/lib/core/helpers/adapters.js +39 -0
- package/lib/core/helpers/chain-address.d.ts +13 -0
- package/lib/core/helpers/chain-address.js +47 -0
- package/lib/core/helpers/chain-error.d.ts +207 -0
- package/lib/core/helpers/chain-error.js +682 -0
- package/lib/core/helpers/chain-support.d.ts +80 -0
- package/lib/core/helpers/chain-support.js +115 -0
- package/lib/core/helpers/core.d.ts +68 -0
- package/lib/core/helpers/core.js +285 -0
- package/lib/core/helpers/explorer-link.d.ts +16 -0
- package/lib/core/helpers/explorer-link.js +26 -0
- package/lib/core/helpers/multicall.d.ts +68 -0
- package/lib/core/helpers/multicall.js +103 -0
- package/lib/core/helpers/revert-decode.d.ts +248 -0
- package/lib/core/helpers/revert-decode.js +515 -0
- package/lib/core/helpers/signer.d.ts +52 -0
- package/lib/core/helpers/signer.js +145 -0
- package/lib/core/helpers/swap-router.d.ts +211 -0
- package/lib/core/helpers/swap-router.js +480 -0
- package/lib/core/helpers/vault-version.d.ts +23 -0
- package/lib/core/helpers/vault-version.js +75 -0
- package/lib/core/helpers/vaults.d.ts +89 -0
- package/lib/core/helpers/vaults.js +235 -0
- package/lib/core/helpers/web3.d.ts +353 -0
- package/lib/core/helpers/web3.js +992 -0
- package/lib/core/index.d.ts +23 -0
- package/lib/core/index.js +40 -0
- package/lib/core/logger/index.d.ts +98 -0
- package/lib/core/logger/index.js +144 -0
- package/lib/core/logger/slack.d.ts +16 -0
- package/lib/core/logger/slack.js +57 -0
- package/lib/core/vault-metadata.d.ts +12 -0
- package/lib/core/vault-metadata.js +42 -0
- package/lib/core/version-check.d.ts +58 -0
- package/lib/core/version-check.js +182 -0
- package/lib/evm/index.d.ts +2 -0
- package/lib/evm/index.js +19 -0
- package/lib/evm/methods/crossChainVault.d.ts +128 -0
- package/lib/evm/methods/crossChainVault.js +853 -0
- package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
- package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
- package/lib/evm/methods/index.d.ts +2 -0
- package/lib/evm/methods/index.js +19 -0
- package/lib/evm/types/crossChain.d.ts +363 -0
- package/lib/evm/types/crossChain.js +20 -0
- package/lib/evm/types/index.d.ts +1 -0
- package/lib/evm/types/index.js +18 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.js +52 -0
- package/lib/main.d.ts +527 -0
- package/lib/main.js +601 -0
- package/lib/modules/api/fetcher.d.ts +82 -0
- package/lib/modules/api/fetcher.js +150 -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 +313 -0
- package/lib/modules/api/main.js +479 -0
- package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
- package/lib/modules/sub-accounts/fetcher.js +120 -0
- package/lib/modules/sub-accounts/index.d.ts +2 -0
- package/lib/modules/sub-accounts/index.js +19 -0
- package/lib/modules/sub-accounts/main.d.ts +243 -0
- package/lib/modules/sub-accounts/main.js +205 -0
- package/lib/modules/sub-accounts/utils.d.ts +106 -0
- package/lib/modules/sub-accounts/utils.js +112 -0
- package/lib/modules/vaults/adapter.helpers.d.ts +64 -0
- package/lib/modules/vaults/adapter.helpers.js +184 -0
- package/lib/modules/vaults/fetcher.d.ts +147 -0
- package/lib/modules/vaults/fetcher.js +368 -0
- package/lib/modules/vaults/getters.d.ts +570 -0
- package/lib/modules/vaults/getters.js +3051 -0
- package/lib/modules/vaults/index.d.ts +20 -0
- package/lib/modules/vaults/index.js +44 -0
- package/lib/modules/vaults/main.d.ts +601 -0
- package/lib/modules/vaults/main.js +1623 -0
- package/lib/modules/vaults/prefetch.d.ts +65 -0
- package/lib/modules/vaults/prefetch.js +120 -0
- package/lib/modules/vaults/read.actions.d.ts +225 -0
- package/lib/modules/vaults/read.actions.js +596 -0
- package/lib/modules/vaults/types.d.ts +71 -0
- package/lib/modules/vaults/types.js +3 -0
- package/lib/modules/vaults/utils/call-data-decoder.d.ts +61 -0
- package/lib/modules/vaults/utils/call-data-decoder.js +194 -0
- package/lib/modules/vaults/utils/date-utils.d.ts +50 -0
- package/lib/modules/vaults/utils/date-utils.js +84 -0
- package/lib/modules/vaults/utils.d.ts +140 -0
- package/lib/modules/vaults/utils.js +799 -0
- package/lib/modules/vaults/write.actions.d.ts +529 -0
- package/lib/modules/vaults/write.actions.js +1749 -0
- package/lib/polyfills.d.ts +1 -0
- package/lib/polyfills.js +12 -0
- package/lib/sdk.d.ts +26721 -0
- package/lib/services/coingecko/fetcher.d.ts +15 -0
- package/lib/services/coingecko/fetcher.js +67 -0
- package/lib/services/coingecko/index.d.ts +2 -0
- package/lib/services/coingecko/index.js +19 -0
- package/lib/services/coingecko/utils.d.ts +1 -0
- package/lib/services/coingecko/utils.js +24 -0
- package/lib/services/debank/fetcher.d.ts +126 -0
- package/lib/services/debank/fetcher.js +47 -0
- package/lib/services/debank/index.d.ts +2 -0
- package/lib/services/debank/index.js +19 -0
- package/lib/services/debank/utils.d.ts +38 -0
- package/lib/services/debank/utils.js +297 -0
- package/lib/services/layerzero/deposits.d.ts +49 -0
- package/lib/services/layerzero/deposits.js +166 -0
- package/lib/services/layerzero/redeems.d.ts +20 -0
- package/lib/services/layerzero/redeems.js +92 -0
- package/lib/services/layerzero/utils.d.ts +9 -0
- package/lib/services/layerzero/utils.js +22 -0
- package/lib/services/octavfi/fetcher.d.ts +9 -0
- package/lib/services/octavfi/fetcher.js +103 -0
- package/lib/services/octavfi/index.d.ts +3 -0
- package/lib/services/octavfi/index.js +20 -0
- package/lib/services/octavfi/types.d.ts +34 -0
- package/lib/services/octavfi/types.js +3 -0
- package/lib/services/octavfi/utils.d.ts +16 -0
- package/lib/services/octavfi/utils.js +212 -0
- package/lib/services/subgraph/fetcher.d.ts +2 -0
- package/lib/services/subgraph/fetcher.js +61 -0
- package/lib/services/subgraph/index.d.ts +2 -0
- package/lib/services/subgraph/index.js +19 -0
- package/lib/services/subgraph/schema.d.ts +45 -0
- package/lib/services/subgraph/schema.js +75 -0
- package/lib/services/subgraph/vaults.d.ts +25 -0
- package/lib/services/subgraph/vaults.js +1106 -0
- package/lib/services/swap-quotes/index.d.ts +105 -0
- package/lib/services/swap-quotes/index.js +77 -0
- package/lib/services/swap-quotes/paraswap.d.ts +51 -0
- package/lib/services/swap-quotes/paraswap.js +138 -0
- package/lib/types/api.d.ts +280 -0
- package/lib/types/api.js +3 -0
- package/lib/types/index.d.ts +12 -0
- package/lib/types/index.js +28 -0
- package/lib/types/points.d.ts +28 -0
- package/lib/types/points.js +3 -0
- package/lib/types/pools.d.ts +144 -0
- package/lib/types/pools.js +3 -0
- package/lib/types/staking.d.ts +28 -0
- package/lib/types/staking.js +3 -0
- package/lib/types/sub-accounts.d.ts +140 -0
- package/lib/types/sub-accounts.js +3 -0
- package/lib/types/subgraph.d.ts +74 -0
- package/lib/types/subgraph.js +3 -0
- package/lib/types/typed-contract.d.ts +102 -0
- package/lib/types/typed-contract.js +3 -0
- package/lib/types/user.d.ts +1 -0
- package/lib/types/user.js +3 -0
- package/lib/types/vaults.d.ts +714 -0
- package/lib/types/vaults.js +24 -0
- package/lib/types/web3.d.ts +51 -0
- package/lib/types/web3.js +14 -0
- package/lib/types/webserver.d.ts +698 -0
- package/lib/types/webserver.js +3 -0
- package/package.json +78 -0
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AugustApi = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const fetcher_1 = require("./fetcher");
|
|
6
|
+
const base_class_1 = require("../../core/base.class");
|
|
7
|
+
const core_1 = require("../../core/constants/core");
|
|
8
|
+
const errors_1 = require("../../core/errors");
|
|
9
|
+
const fetcher_2 = require("../../core/fetcher");
|
|
10
|
+
const chain_address_1 = require("../../core/helpers/chain-address");
|
|
11
|
+
function toUnrealizedPnlSnapshot(raw) {
|
|
12
|
+
return {
|
|
13
|
+
timestamp: raw.timestamp,
|
|
14
|
+
vaultName: raw.vault_name,
|
|
15
|
+
vaultAddress: raw.vault_address,
|
|
16
|
+
strategistName: raw.strategist_name ?? null,
|
|
17
|
+
referenceAsset: raw.reference_asset,
|
|
18
|
+
assetPrice: raw.asset_price,
|
|
19
|
+
tvlOnVault: raw.tvl_on_vault,
|
|
20
|
+
currentRedeemRatio: raw.current_redeem_ratio,
|
|
21
|
+
actualTvl: raw.actual_tvl,
|
|
22
|
+
adjustedRedeemRatio: raw.adjusted_redeem_ratio,
|
|
23
|
+
unrealizedPnl: raw.unrealized_pnl,
|
|
24
|
+
unrealizedPnlInAsset: raw.unrealized_pnl_in_asset,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function assertVaultAddress(vault, method) {
|
|
28
|
+
const valid = typeof vault === 'string' &&
|
|
29
|
+
vault.length > 0 &&
|
|
30
|
+
((0, ethers_1.isAddress)(vault) || (0, chain_address_1.isSolanaAddress)(vault) || (0, chain_address_1.isStellarAddress)(vault));
|
|
31
|
+
if (!valid) {
|
|
32
|
+
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.`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function assertAddressArg(value, label, method) {
|
|
36
|
+
const valid = typeof value === 'string' &&
|
|
37
|
+
value.length > 0 &&
|
|
38
|
+
((0, ethers_1.isAddress)(value) || (0, chain_address_1.isSolanaAddress)(value) || (0, chain_address_1.isStellarAddress)(value));
|
|
39
|
+
if (!valid) {
|
|
40
|
+
throw new errors_1.AugustValidationError('INVALID_ADDRESS', `${method}: "${value}" is not a valid ${label} — pass an EVM (0x…), Solana, or Stellar address.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const SNAPSHOT_STRING_FIELDS = [
|
|
44
|
+
'timestamp',
|
|
45
|
+
'vault_name',
|
|
46
|
+
'vault_address',
|
|
47
|
+
'reference_asset',
|
|
48
|
+
];
|
|
49
|
+
const SNAPSHOT_NUMBER_FIELDS = [
|
|
50
|
+
'asset_price',
|
|
51
|
+
'tvl_on_vault',
|
|
52
|
+
'current_redeem_ratio',
|
|
53
|
+
'actual_tvl',
|
|
54
|
+
'adjusted_redeem_ratio',
|
|
55
|
+
'unrealized_pnl',
|
|
56
|
+
'unrealized_pnl_in_asset',
|
|
57
|
+
];
|
|
58
|
+
function isRawSnapshot(item) {
|
|
59
|
+
if (!item || typeof item !== 'object')
|
|
60
|
+
return false;
|
|
61
|
+
const record = item;
|
|
62
|
+
return (SNAPSHOT_STRING_FIELDS.every((field) => typeof record[field] === 'string') &&
|
|
63
|
+
SNAPSHOT_NUMBER_FIELDS.every((field) => typeof record[field] === 'number'));
|
|
64
|
+
}
|
|
65
|
+
function assertSnapshotArray(data, method) {
|
|
66
|
+
const valid = Array.isArray(data) && data.every(isRawSnapshot);
|
|
67
|
+
if (!valid) {
|
|
68
|
+
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.`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Read-only client for August backend REST endpoints that have no on-chain
|
|
73
|
+
* equivalent — currently the unrealized-PnL series the backend computes
|
|
74
|
+
* from periodic vault snapshots.
|
|
75
|
+
*
|
|
76
|
+
* Every method makes exactly one HTTPS request to the public
|
|
77
|
+
* (unauthenticated) August API and zero RPC calls. Responses are not cached
|
|
78
|
+
* by the SDK: this is time-sensitive PnL state where staleness is worse
|
|
79
|
+
* than request latency.
|
|
80
|
+
*
|
|
81
|
+
* Accessible as `apiModule` on the SDK instance; the same methods are also
|
|
82
|
+
* exposed directly on the SDK class.
|
|
83
|
+
*
|
|
84
|
+
* A subset of methods (loan book, risk) hit authenticated admin-only backend
|
|
85
|
+
* endpoints and require an admin-scoped August API key on the SDK
|
|
86
|
+
* constructor; each such method documents the requirement.
|
|
87
|
+
*/
|
|
88
|
+
class AugustApi extends base_class_1.AugustBase {
|
|
89
|
+
headers = null;
|
|
90
|
+
constructor(baseConfig) {
|
|
91
|
+
super(baseConfig);
|
|
92
|
+
this.headers = {
|
|
93
|
+
'x-environment': this.monitoring?.['x-environment'],
|
|
94
|
+
'x-user-id': this.monitoring?.['x-user-id'],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Retrieve the global loan-book aggregate across every active client
|
|
99
|
+
* subaccount — one {@link ILoanBookInfo} entry per loan, with principal /
|
|
100
|
+
* interest amounts, APRs, state, and the next upcoming payment.
|
|
101
|
+
*
|
|
102
|
+
* Backed by the admin-only `GET /dashboard/loans` backend endpoint (60-second
|
|
103
|
+
* server-side cache), so the August API key configured on the SDK must
|
|
104
|
+
* belong to an admin user. Makes exactly one HTTP request and no RPC calls.
|
|
105
|
+
*
|
|
106
|
+
* @returns Array of loan-book entries; empty when there are no active loans.
|
|
107
|
+
* @throws AugustAuthError When the API key is missing or not admin-scoped.
|
|
108
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
109
|
+
* @example
|
|
110
|
+
* const loans = await sdk.apiModule.getDashboardLoans();
|
|
111
|
+
* const active = loans.filter((l) => l.state === 'ACTIVE');
|
|
112
|
+
*/
|
|
113
|
+
async getDashboardLoans() {
|
|
114
|
+
return (0, fetcher_1.fetchDashboardLoans)(this.keys.august, this.headers ?? undefined);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Retrieve every token discount-factor ladder the risk engine applies when
|
|
118
|
+
* valuing collateral.
|
|
119
|
+
*
|
|
120
|
+
* Backed by `GET /risk/discount_factors` (60-second server-side cache),
|
|
121
|
+
* which requires an authenticated August user; an admin-scoped API key
|
|
122
|
+
* works. Makes exactly one HTTP request and no RPC calls.
|
|
123
|
+
*
|
|
124
|
+
* @returns Array of {@link IDiscountFactorLadder}, one per whitelisted token that has a configured ladder.
|
|
125
|
+
* @throws AugustAuthError When the API key is missing or not authorized.
|
|
126
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
127
|
+
* @example
|
|
128
|
+
* const ladders = await sdk.apiModule.getDiscountFactors();
|
|
129
|
+
* console.log(ladders.map((d) => `${d.address}@${d.chain}`));
|
|
130
|
+
*/
|
|
131
|
+
async getDiscountFactors() {
|
|
132
|
+
return (0, fetcher_1.fetchDiscountFactors)(this.keys.august, this.headers ?? undefined);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Compute how much collateral a subaccount has in excess of — or is short
|
|
136
|
+
* of — what it needs to hold a target health factor, for one collateral
|
|
137
|
+
* token.
|
|
138
|
+
*
|
|
139
|
+
* Backed by `GET /risk/collateral_excess_or_deficit` (60-second server-side
|
|
140
|
+
* cache), which resolves the subaccount and reads its current health factor,
|
|
141
|
+
* so an authenticated (admin-scoped) August API key is required. Makes
|
|
142
|
+
* exactly one HTTP request and no RPC calls.
|
|
143
|
+
*
|
|
144
|
+
* @param params.subaccount Subaccount (smart-contract wallet) address.
|
|
145
|
+
* @param params.tokenAddress Collateral token address to evaluate.
|
|
146
|
+
* @param params.tokenChain Numeric August chain id of the token (e.g. `1` for Ethereum mainnet).
|
|
147
|
+
* @param params.targetHealthFactor Health factor to solve for. Defaults server-side to the minimum healthy factor (1.2); when supplied must be a finite number greater than 0.
|
|
148
|
+
* @returns The signed excess (positive) or deficit (negative) in USD and token units. Zeroes when the subaccount has no debt.
|
|
149
|
+
* @throws AugustValidationError When an address is invalid, `tokenChain` is not an integer, or `targetHealthFactor` is out of range.
|
|
150
|
+
* @throws AugustServerError When the token has no discount factor (backend 404) or the API otherwise responds non-2xx.
|
|
151
|
+
* @example
|
|
152
|
+
* const r = await sdk.apiModule.getCollateralExcessOrDeficit({
|
|
153
|
+
* subaccount: '0xabc…',
|
|
154
|
+
* tokenAddress: '0xdef…',
|
|
155
|
+
* tokenChain: 1,
|
|
156
|
+
* });
|
|
157
|
+
* console.log(r.amount_usd > 0 ? 'excess' : 'deficit');
|
|
158
|
+
*/
|
|
159
|
+
async getCollateralExcessOrDeficit(params) {
|
|
160
|
+
const method = 'getCollateralExcessOrDeficit';
|
|
161
|
+
assertAddressArg(params.subaccount, 'subaccount address', method);
|
|
162
|
+
assertAddressArg(params.tokenAddress, 'token address', method);
|
|
163
|
+
if (!Number.isInteger(params.tokenChain)) {
|
|
164
|
+
throw new errors_1.AugustValidationError('INVALID_CHAIN', `${method}: tokenChain must be an integer August chain id, got ${params.tokenChain}.`);
|
|
165
|
+
}
|
|
166
|
+
if (params.targetHealthFactor !== undefined &&
|
|
167
|
+
(!Number.isFinite(params.targetHealthFactor) ||
|
|
168
|
+
params.targetHealthFactor <= 0)) {
|
|
169
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: targetHealthFactor must be a finite number greater than 0, got ${params.targetHealthFactor}.`);
|
|
170
|
+
}
|
|
171
|
+
return (0, fetcher_1.fetchCollateralExcessOrDeficit)(params, this.keys.august, this.headers ?? undefined);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Simulate the collateral required to open a hypothetical loan against a
|
|
175
|
+
* chosen basket of collateral tokens.
|
|
176
|
+
*
|
|
177
|
+
* This is a pure, read-only simulation: the backend `POST
|
|
178
|
+
* /risk/collateral_simulation` endpoint (60-second server-side cache)
|
|
179
|
+
* computes required collateral and effective discount factors and changes
|
|
180
|
+
* no state. It runs against the authenticated backend, so an
|
|
181
|
+
* (admin-scoped) August API key is required. Makes exactly one HTTP request
|
|
182
|
+
* and no RPC calls.
|
|
183
|
+
*
|
|
184
|
+
* @param input Simulation parameters — see {@link ICollateralSimulationInput}. `collateral_tokens` and `collateral_token_allocation` must be non-empty and equal length; when `on_platform` is `true`, both `loan_redeployed_token_*` fields are required.
|
|
185
|
+
* @returns The simulated {@link ICollateralSimulationResults}: total debt, required collateral, resulting health factor, and a per-token breakdown.
|
|
186
|
+
* @throws AugustValidationError When addresses are invalid, `loan_amount` is not a finite non-negative number, the collateral arrays are empty / mismatched, or `on_platform` is set without redeployed-token details.
|
|
187
|
+
* @throws AugustServerError When the API responds with a non-2xx status (e.g. a token missing a discount factor).
|
|
188
|
+
* @example
|
|
189
|
+
* const sim = await sdk.apiModule.simulateCollateral({
|
|
190
|
+
* loan_token_chain: 1,
|
|
191
|
+
* loan_token_address: '0xloan…',
|
|
192
|
+
* loan_amount: 1_000_000,
|
|
193
|
+
* collateral_tokens: [[1, '0xcol…']],
|
|
194
|
+
* collateral_token_allocation: [1],
|
|
195
|
+
* });
|
|
196
|
+
* console.log(sim.total_required_collateral_usd);
|
|
197
|
+
*/
|
|
198
|
+
async simulateCollateral(input) {
|
|
199
|
+
const method = 'simulateCollateral';
|
|
200
|
+
assertAddressArg(input.loan_token_address, 'loan token address', method);
|
|
201
|
+
if (!Number.isFinite(input.loan_amount) || input.loan_amount < 0) {
|
|
202
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: loan_amount must be a finite non-negative number, got ${input.loan_amount}.`);
|
|
203
|
+
}
|
|
204
|
+
if (!Array.isArray(input.collateral_tokens) ||
|
|
205
|
+
input.collateral_tokens.length === 0 ||
|
|
206
|
+
!Array.isArray(input.collateral_token_allocation) ||
|
|
207
|
+
input.collateral_token_allocation.length === 0) {
|
|
208
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: collateral_tokens and collateral_token_allocation must both be non-empty.`);
|
|
209
|
+
}
|
|
210
|
+
if (input.collateral_tokens.length !==
|
|
211
|
+
input.collateral_token_allocation.length) {
|
|
212
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: collateral_tokens (${input.collateral_tokens.length}) and collateral_token_allocation (${input.collateral_token_allocation.length}) must be the same length.`);
|
|
213
|
+
}
|
|
214
|
+
for (const [, address] of input.collateral_tokens) {
|
|
215
|
+
assertAddressArg(address, 'collateral token address', method);
|
|
216
|
+
}
|
|
217
|
+
if (input.on_platform &&
|
|
218
|
+
(input.loan_redeployed_token_chain === undefined ||
|
|
219
|
+
input.loan_redeployed_token_chain === null ||
|
|
220
|
+
!input.loan_redeployed_token_address)) {
|
|
221
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: on_platform requires both loan_redeployed_token_chain and loan_redeployed_token_address.`);
|
|
222
|
+
}
|
|
223
|
+
return (0, fetcher_1.fetchCollateralSimulation)(input, this.keys.august, this.headers ?? undefined);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Fetch the decoded revert reason(s) for a transaction — error messages,
|
|
227
|
+
* revert strings, and recognized universal-subaccount errors extracted from
|
|
228
|
+
* a `debug_traceTransaction` call tree.
|
|
229
|
+
*
|
|
230
|
+
* Backed by the public (unauthenticated) `GET /revert_reason` endpoint; no
|
|
231
|
+
* API key required. The backend relies on the target chain's RPC supporting
|
|
232
|
+
* `debug_trace*`; on chains/RPCs without it the backend returns a 5xx whose
|
|
233
|
+
* detail explains why, surfaced here as an {@link AugustServerError}. Makes
|
|
234
|
+
* exactly one HTTP request and no RPC calls from the SDK itself.
|
|
235
|
+
*
|
|
236
|
+
* @param txHash Transaction hash to trace.
|
|
237
|
+
* @param chain Numeric August chain id the transaction is on (e.g. `1` for Ethereum mainnet).
|
|
238
|
+
* @returns The decoded {@link IRevertReason}; all arrays empty when the trace yielded no matching signal.
|
|
239
|
+
* @throws AugustValidationError When `txHash` is empty or `chain` is not an integer.
|
|
240
|
+
* @throws AugustServerError When the chain/RPC does not support tracing, or the API otherwise responds non-2xx.
|
|
241
|
+
* @example
|
|
242
|
+
* const r = await sdk.apiModule.getRevertReason('0xabc…', 1);
|
|
243
|
+
* console.log(r.revert_reasons);
|
|
244
|
+
*/
|
|
245
|
+
async getRevertReason(txHash, chain) {
|
|
246
|
+
const method = 'getRevertReason';
|
|
247
|
+
if (typeof txHash !== 'string' || txHash.trim().length === 0) {
|
|
248
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: txHash must be a non-empty transaction hash.`);
|
|
249
|
+
}
|
|
250
|
+
if (!Number.isInteger(chain)) {
|
|
251
|
+
throw new errors_1.AugustValidationError('INVALID_CHAIN', `${method}: chain must be an integer August chain id, got ${chain}.`);
|
|
252
|
+
}
|
|
253
|
+
return (0, fetcher_1.fetchRevertReason)(txHash, chain, this.headers ?? undefined);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Retrieve every tracked OTC position.
|
|
257
|
+
*
|
|
258
|
+
* Backed by the admin-only `GET /otc/position` backend endpoint, so the
|
|
259
|
+
* configured August API key must belong to an admin user. Makes exactly one
|
|
260
|
+
* HTTP request and no RPC calls.
|
|
261
|
+
*
|
|
262
|
+
* @returns Array of {@link IOtcPositionRead}; empty when there are no OTC positions.
|
|
263
|
+
* @throws AugustAuthError When the API key is missing or not admin-scoped.
|
|
264
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
265
|
+
* @example
|
|
266
|
+
* const positions = await sdk.apiModule.getOtcPositions();
|
|
267
|
+
*/
|
|
268
|
+
async getOtcPositions() {
|
|
269
|
+
return (0, fetcher_1.fetchOtcPositions)(this.keys.august, this.headers ?? undefined);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Retrieve OTC margin requirements, optionally filtered by counterparty
|
|
273
|
+
* and/or payer.
|
|
274
|
+
*
|
|
275
|
+
* Backed by the admin-only `GET /otc/margin_requirement` backend endpoint,
|
|
276
|
+
* so the configured August API key must belong to an admin user. Makes
|
|
277
|
+
* exactly one HTTP request and no RPC calls.
|
|
278
|
+
*
|
|
279
|
+
* @param options - Optional filters
|
|
280
|
+
* @param options.otcCounterpartyId - Restrict to a single counterparty (UUID)
|
|
281
|
+
* @param options.payer - Restrict to a single payer address
|
|
282
|
+
* @returns Array of {@link IOtcMarginRequirement} matching the filters (all when none given).
|
|
283
|
+
* @throws AugustAuthError When the API key is missing or not admin-scoped.
|
|
284
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
285
|
+
* @example
|
|
286
|
+
* const reqs = await sdk.apiModule.getOtcMarginRequirements({ payer: '0xabc…' });
|
|
287
|
+
*/
|
|
288
|
+
async getOtcMarginRequirements(options = {}) {
|
|
289
|
+
return (0, fetcher_1.fetchOtcMarginRequirements)(options, this.keys.august, this.headers ?? undefined);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* List the subaccounts linked to a vault (curator surface).
|
|
293
|
+
*
|
|
294
|
+
* Backed by the curator-or-admin `GET
|
|
295
|
+
* /curator/vaults/{vault_address}/subaccounts` backend endpoint, so the
|
|
296
|
+
* configured August API key must belong to the vault's curator or an admin.
|
|
297
|
+
* Makes exactly one HTTP request and no RPC calls.
|
|
298
|
+
*
|
|
299
|
+
* @param vaultAddress - The vault address (EVM `0x…`, Solana, or Stellar)
|
|
300
|
+
* @returns Array of subaccount records linked to the vault (same shape as the subaccount directory); empty when none are linked.
|
|
301
|
+
* @throws AugustValidationError When `vaultAddress` is not a valid address.
|
|
302
|
+
* @throws AugustAuthError When the API key is missing or not curator/admin for the vault.
|
|
303
|
+
* @throws AugustServerError When the API responds with a non-2xx status.
|
|
304
|
+
* @example
|
|
305
|
+
* const subs = await sdk.apiModule.getCuratorVaultSubaccounts('0xvault…');
|
|
306
|
+
*/
|
|
307
|
+
async getCuratorVaultSubaccounts(vaultAddress) {
|
|
308
|
+
assertVaultAddress(vaultAddress, 'getCuratorVaultSubaccounts');
|
|
309
|
+
return (0, fetcher_1.fetchCuratorVaultSubaccounts)(vaultAddress, this.keys.august, this.headers ?? undefined);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Get on-chain whitelist status for every subaccount linked to a vault
|
|
313
|
+
* (curator surface).
|
|
314
|
+
*
|
|
315
|
+
* Backed by the curator-or-admin `GET
|
|
316
|
+
* /curator/vaults/{vault_address}/whitelist` backend endpoint. EVM vaults
|
|
317
|
+
* only — non-EVM vaults manage access internally and the backend returns a
|
|
318
|
+
* 400 (surfaced as {@link AugustServerError}). Makes exactly one HTTP
|
|
319
|
+
* request and no RPC calls from the SDK.
|
|
320
|
+
*
|
|
321
|
+
* @param vaultAddress - The EVM vault address (`0x…`)
|
|
322
|
+
* @returns Array of {@link ICuratorWhitelistStatus}, one per linked subaccount; empty when the vault has no subaccounts.
|
|
323
|
+
* @throws AugustValidationError When `vaultAddress` is not a valid address.
|
|
324
|
+
* @throws AugustAuthError When the API key is missing or not curator/admin for the vault.
|
|
325
|
+
* @throws AugustServerError When the vault is non-EVM (backend 400) or the API otherwise responds non-2xx.
|
|
326
|
+
* @example
|
|
327
|
+
* const status = await sdk.apiModule.getCuratorVaultWhitelist('0xvault…');
|
|
328
|
+
* console.log(status.filter((s) => !s.is_whitelisted));
|
|
329
|
+
*/
|
|
330
|
+
async getCuratorVaultWhitelist(vaultAddress) {
|
|
331
|
+
assertVaultAddress(vaultAddress, 'getCuratorVaultWhitelist');
|
|
332
|
+
return (0, fetcher_1.fetchCuratorVaultWhitelist)(vaultAddress, this.keys.august, this.headers ?? undefined);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* List timelock (governance) requests for a vault on a chain, optionally
|
|
336
|
+
* filtered by status.
|
|
337
|
+
*
|
|
338
|
+
* Backed by the `GET /timelock-requests` backend endpoint. Makes exactly one
|
|
339
|
+
* HTTP request and no RPC calls.
|
|
340
|
+
*
|
|
341
|
+
* @param params.vaultAddress The vault address the requests target.
|
|
342
|
+
* @param params.chainId Numeric August chain id (must be a positive integer).
|
|
343
|
+
* @param params.status Status filter: `"scheduled"` (backend default), `"executed"`, `"cancelled"`, or `"all"`. Omit to use the backend default.
|
|
344
|
+
* @returns Array of {@link ITimelockRequest}; empty when the vault has no matching requests.
|
|
345
|
+
* @throws AugustValidationError When `vaultAddress` is invalid or `chainId` is not a positive integer.
|
|
346
|
+
* @throws AugustServerError When the API responds with a non-2xx status (e.g. an invalid status filter).
|
|
347
|
+
* @example
|
|
348
|
+
* const reqs = await sdk.apiModule.getTimelockRequests({ vaultAddress: '0xvault…', chainId: 1 });
|
|
349
|
+
*/
|
|
350
|
+
async getTimelockRequests(params) {
|
|
351
|
+
const method = 'getTimelockRequests';
|
|
352
|
+
assertVaultAddress(params.vaultAddress, method);
|
|
353
|
+
if (!Number.isInteger(params.chainId) || params.chainId <= 0) {
|
|
354
|
+
throw new errors_1.AugustValidationError('INVALID_CHAIN', `${method}: chainId must be a positive integer August chain id, got ${params.chainId}.`);
|
|
355
|
+
}
|
|
356
|
+
return (0, fetcher_1.fetchTimelockRequests)(params, this.keys.august, this.headers ?? undefined);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Compute a vault's performance fees over a period (backend-computed from
|
|
360
|
+
* its snapshot history).
|
|
361
|
+
*
|
|
362
|
+
* Backed by `GET /metrics/vault_performance_fees`. The backend runs pandas
|
|
363
|
+
* over the vault's full snapshot history, so the first call is slow; results
|
|
364
|
+
* are cached server-side for 20 minutes. Makes exactly one HTTP request and
|
|
365
|
+
* no RPC calls.
|
|
366
|
+
*
|
|
367
|
+
* @param params.vault The vault address (EVM `0x…`, Solana, or Stellar).
|
|
368
|
+
* @param params.annualizedFeesPct Annualized performance-fee percentage. Defaults to 20.
|
|
369
|
+
* @param params.nativeDenominated Whether to denominate in the vault's native token. Defaults to `true`.
|
|
370
|
+
* @param params.calculationPeriod Period preset — `"YearToDate"` (default) or `"MonthToDate"`. Ignored by the backend when a custom `startDate`/`endDate` range is supplied.
|
|
371
|
+
* @param params.startDate ISO-8601 datetime range start. Must be supplied together with `endDate`.
|
|
372
|
+
* @param params.endDate ISO-8601 datetime range end. Must be supplied together with `startDate`.
|
|
373
|
+
* @returns The vault's {@link IVaultPerformanceFees} computation.
|
|
374
|
+
* @throws AugustValidationError When `vault` is invalid, or exactly one of `startDate`/`endDate` is supplied.
|
|
375
|
+
* @throws AugustServerError When there is insufficient snapshot data for the period, or the API otherwise responds non-2xx.
|
|
376
|
+
* @example
|
|
377
|
+
* const fees = await sdk.apiModule.getVaultPerformanceFees({ vault: '0xvault…' });
|
|
378
|
+
* console.log(fees.total_perf_fees_asset);
|
|
379
|
+
*/
|
|
380
|
+
async getVaultPerformanceFees(params) {
|
|
381
|
+
const method = 'getVaultPerformanceFees';
|
|
382
|
+
assertVaultAddress(params.vault, method);
|
|
383
|
+
const hasStart = params.startDate !== undefined;
|
|
384
|
+
const hasEnd = params.endDate !== undefined;
|
|
385
|
+
if (hasStart !== hasEnd) {
|
|
386
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: startDate and endDate must be supplied together (both or neither).`);
|
|
387
|
+
}
|
|
388
|
+
return (0, fetcher_1.fetchVaultPerformanceFees)({
|
|
389
|
+
vaultAddress: params.vault,
|
|
390
|
+
annualizedFeesPct: params.annualizedFeesPct ?? 20,
|
|
391
|
+
nativeDenominated: params.nativeDenominated ?? true,
|
|
392
|
+
calculationPeriod: params.calculationPeriod ?? 'YearToDate',
|
|
393
|
+
startDate: params.startDate,
|
|
394
|
+
endDate: params.endDate,
|
|
395
|
+
}, this.keys.august, this.headers ?? undefined);
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Fetch a vault's NAV-oracle classification table — how each position/token
|
|
399
|
+
* is priced (Primary / Secondary Market / CeFi) and its USD value, plus
|
|
400
|
+
* warnings for tokens that could not be resolved.
|
|
401
|
+
*
|
|
402
|
+
* Backed by the public (unauthenticated) `GET
|
|
403
|
+
* /upshift/oracle_classification/{vault_address}` endpoint; no API key
|
|
404
|
+
* required. Reads the newest daily snapshot. Makes exactly one HTTP request
|
|
405
|
+
* and no RPC calls from the SDK.
|
|
406
|
+
*
|
|
407
|
+
* @param vault The vault address (EVM `0x…`, Solana, or Stellar).
|
|
408
|
+
* @param chainId Numeric August chain id the vault lives on.
|
|
409
|
+
* @returns The vault's {@link IOracleClassification}.
|
|
410
|
+
* @throws AugustValidationError When `vault` is invalid or `chainId` is not an integer.
|
|
411
|
+
* @throws AugustServerError When the vault or its snapshot is not found, or the API otherwise responds non-2xx.
|
|
412
|
+
* @example
|
|
413
|
+
* const cls = await sdk.apiModule.getVaultOracleClassification('0xvault…', 1);
|
|
414
|
+
* console.log(cls.warnings);
|
|
415
|
+
*/
|
|
416
|
+
async getVaultOracleClassification(vault, chainId) {
|
|
417
|
+
const method = 'getVaultOracleClassification';
|
|
418
|
+
assertVaultAddress(vault, method);
|
|
419
|
+
if (!Number.isInteger(chainId)) {
|
|
420
|
+
throw new errors_1.AugustValidationError('INVALID_CHAIN', `${method}: chainId must be an integer August chain id, got ${chainId}.`);
|
|
421
|
+
}
|
|
422
|
+
return (0, fetcher_1.fetchVaultOracleClassification)(vault, chainId, this.headers ?? undefined);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Fetch the historical unrealized-PnL series for a vault, newest first,
|
|
426
|
+
* as computed by the August backend from periodic vault snapshots.
|
|
427
|
+
*
|
|
428
|
+
* Makes one HTTPS request to the public August API; no RPC calls.
|
|
429
|
+
*
|
|
430
|
+
* @param params.vault Vault address (EVM `0x…`, Solana, or Stellar).
|
|
431
|
+
* @param params.limit Maximum number of snapshots to return (1–1000). Backend default applies when omitted.
|
|
432
|
+
* @returns Array of {@link IUnrealizedPnlSnapshot}; empty when the backend has no history for the vault.
|
|
433
|
+
* @throws AugustValidationError When `vault` is not a valid address or `limit` is out of range.
|
|
434
|
+
* @throws AugustServerError When the API responds with a 5xx, or returns a body that is not a snapshot array.
|
|
435
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
436
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
437
|
+
* @example
|
|
438
|
+
* const series = await sdk.getVaultUnrealizedPnlHistory({ vault: '0x36eDbF0C834591BFdfCaC0Ef9605528c75c406aA', limit: 30 });
|
|
439
|
+
* console.log(series[0]?.unrealizedPnlInAsset);
|
|
440
|
+
*/
|
|
441
|
+
async getVaultUnrealizedPnlHistory(params) {
|
|
442
|
+
const method = 'getVaultUnrealizedPnlHistory';
|
|
443
|
+
assertVaultAddress(params.vault, method);
|
|
444
|
+
if (params.limit !== undefined &&
|
|
445
|
+
(!Number.isInteger(params.limit) ||
|
|
446
|
+
params.limit < 1 ||
|
|
447
|
+
params.limit > 1000)) {
|
|
448
|
+
throw new errors_1.AugustValidationError('INVALID_INPUT', `${method}: limit must be an integer between 1 and 1000, got ${params.limit}.`);
|
|
449
|
+
}
|
|
450
|
+
const endpoint = core_1.WEBSERVER_ENDPOINTS.public.pnl.unrealizedHistory(params.vault, params.limit);
|
|
451
|
+
const response = await (0, fetcher_2.fetchAugustPublic)(endpoint);
|
|
452
|
+
const data = await response.json();
|
|
453
|
+
assertSnapshotArray(data, method);
|
|
454
|
+
return data.map(toUnrealizedPnlSnapshot);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Fetch the latest unrealized-PnL snapshot for every vault the backend
|
|
458
|
+
* tracks — one entry per vault.
|
|
459
|
+
*
|
|
460
|
+
* Makes one HTTPS request to the public August API; no RPC calls.
|
|
461
|
+
*
|
|
462
|
+
* @returns Array of {@link IUnrealizedPnlSnapshot}, one per tracked vault.
|
|
463
|
+
* @throws AugustServerError When the API responds with a 5xx, or returns a body that is not a snapshot array.
|
|
464
|
+
* @throws AugustRateLimitError When the API responds 429.
|
|
465
|
+
* @throws AugustTimeoutError When the request exceeds the SDK request timeout.
|
|
466
|
+
* @example
|
|
467
|
+
* const all = await sdk.getLatestUnrealizedPnl();
|
|
468
|
+
* const losing = all.filter((s) => s.unrealizedPnl < 0);
|
|
469
|
+
*/
|
|
470
|
+
async getLatestUnrealizedPnl() {
|
|
471
|
+
const method = 'getLatestUnrealizedPnl';
|
|
472
|
+
const response = await (0, fetcher_2.fetchAugustPublic)(core_1.WEBSERVER_ENDPOINTS.public.pnl.unrealizedLatest);
|
|
473
|
+
const data = await response.json();
|
|
474
|
+
assertSnapshotArray(data, method);
|
|
475
|
+
return data.map(toUnrealizedPnlSnapshot);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
exports.AugustApi = AugustApi;
|
|
479
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type IFetchAugustOptions } from '../../core';
|
|
2
|
+
import type { IAddress, ILoanBookInfo, IOTCPosition, ISubaccountDebank, ISubaccountTransaction, IWSSubaccountCefi, IWSSubAccountHealthFactor, IWSSubaccountListItem, IWSSubaccountLoan, IWSSubaccountSummary } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Fetch one page of the subaccount directory (admin-only backend endpoint)
|
|
5
|
+
*/
|
|
6
|
+
export declare const fetchAllSubaccounts: (pagination: {
|
|
7
|
+
offset?: number;
|
|
8
|
+
limit?: number;
|
|
9
|
+
}, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountListItem[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Fetch a subaccount's transaction history (authenticated `GET
|
|
12
|
+
* /transactions/v2`), optionally windowed by ISO-8601 start/end datetimes.
|
|
13
|
+
*/
|
|
14
|
+
export declare const fetchSubaccountTransactions: (payload: {
|
|
15
|
+
address: IAddress;
|
|
16
|
+
startTime?: string;
|
|
17
|
+
endTime?: string;
|
|
18
|
+
}, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ISubaccountTransaction[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch a single loan's loan-book detail by loan address + chain
|
|
21
|
+
* (admin-only `GET /subaccount/loans/{loan_address}`).
|
|
22
|
+
*/
|
|
23
|
+
export declare const fetchSubaccountLoanByAddress: (loanAddress: string, chainId: number, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ILoanBookInfo>;
|
|
24
|
+
/**
|
|
25
|
+
* Fetch cross-chain DeBank positions for a subaccount (`GET
|
|
26
|
+
* /subaccount/{subaccount_address}/debank`). Slow endpoint (300-second
|
|
27
|
+
* server-side cache) — it fans out across every supported chain.
|
|
28
|
+
*/
|
|
29
|
+
export declare const fetchSubaccountDebank: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<ISubaccountDebank>;
|
|
30
|
+
/**
|
|
31
|
+
* Fetch subaccount health factor for a given subaccount address
|
|
32
|
+
*/
|
|
33
|
+
export declare const fetchSubaccountHeathFactor: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubAccountHealthFactor>;
|
|
34
|
+
/**
|
|
35
|
+
* Fetch subaccount loans details
|
|
36
|
+
*/
|
|
37
|
+
export declare const fetchSubaccountLoans: (payload: {
|
|
38
|
+
address: IAddress;
|
|
39
|
+
side?: "BOTH" | "BORROWER" | "LENDER";
|
|
40
|
+
active?: boolean;
|
|
41
|
+
}, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountLoan[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Fetch the subaccount CeFi positions
|
|
44
|
+
*/
|
|
45
|
+
export declare const fetchSubaccountCefiPositions: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountCefi[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Fetch the subaccount OTC positions
|
|
48
|
+
*/
|
|
49
|
+
export declare const fetchSubaccountOtcPositions: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IOTCPosition[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Fetch the subaccount summary view
|
|
52
|
+
*/
|
|
53
|
+
export declare const fetchSubaccountSummary: (address: IAddress, augustKey: string, headers?: IFetchAugustOptions["headers"]) => Promise<IWSSubaccountSummary>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchSubaccountSummary = exports.fetchSubaccountOtcPositions = exports.fetchSubaccountCefiPositions = exports.fetchSubaccountLoans = exports.fetchSubaccountHeathFactor = exports.fetchSubaccountDebank = exports.fetchSubaccountLoanByAddress = exports.fetchSubaccountTransactions = exports.fetchAllSubaccounts = void 0;
|
|
4
|
+
const core_1 = require("../../core");
|
|
5
|
+
/**
|
|
6
|
+
* Fetch one page of the subaccount directory (admin-only backend endpoint)
|
|
7
|
+
*/
|
|
8
|
+
const fetchAllSubaccounts = async (pagination, augustKey, headers) => {
|
|
9
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.list(pagination.offset, pagination.limit), {
|
|
10
|
+
headers,
|
|
11
|
+
});
|
|
12
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
13
|
+
throw new Error(`Failed to fetch subaccounts: ${response.statusText || 'Unknown error'}`);
|
|
14
|
+
}
|
|
15
|
+
return response.json();
|
|
16
|
+
};
|
|
17
|
+
exports.fetchAllSubaccounts = fetchAllSubaccounts;
|
|
18
|
+
/**
|
|
19
|
+
* Fetch a subaccount's transaction history (authenticated `GET
|
|
20
|
+
* /transactions/v2`), optionally windowed by ISO-8601 start/end datetimes.
|
|
21
|
+
*/
|
|
22
|
+
const fetchSubaccountTransactions = async (payload, augustKey, headers) => {
|
|
23
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.transactions.v2(payload.address, payload.startTime, payload.endTime), { headers });
|
|
24
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
25
|
+
throw new Error(`Failed to fetch subaccount transactions: ${response.statusText || 'Unknown error'}`);
|
|
26
|
+
}
|
|
27
|
+
return response.json();
|
|
28
|
+
};
|
|
29
|
+
exports.fetchSubaccountTransactions = fetchSubaccountTransactions;
|
|
30
|
+
/**
|
|
31
|
+
* Fetch a single loan's loan-book detail by loan address + chain
|
|
32
|
+
* (admin-only `GET /subaccount/loans/{loan_address}`).
|
|
33
|
+
*/
|
|
34
|
+
const fetchSubaccountLoanByAddress = async (loanAddress, chainId, augustKey, headers) => {
|
|
35
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.loanByAddress(loanAddress, chainId), { headers });
|
|
36
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
37
|
+
throw new Error(`Failed to fetch loan by address: ${response.statusText || 'Unknown error'}`);
|
|
38
|
+
}
|
|
39
|
+
return response.json();
|
|
40
|
+
};
|
|
41
|
+
exports.fetchSubaccountLoanByAddress = fetchSubaccountLoanByAddress;
|
|
42
|
+
/**
|
|
43
|
+
* Fetch cross-chain DeBank positions for a subaccount (`GET
|
|
44
|
+
* /subaccount/{subaccount_address}/debank`). Slow endpoint (300-second
|
|
45
|
+
* server-side cache) — it fans out across every supported chain.
|
|
46
|
+
*/
|
|
47
|
+
const fetchSubaccountDebank = async (address, augustKey, headers) => {
|
|
48
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.debank(address), { headers });
|
|
49
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
50
|
+
throw new Error(`Failed to fetch subaccount debank: ${response.statusText || 'Unknown error'}`);
|
|
51
|
+
}
|
|
52
|
+
return response.json();
|
|
53
|
+
};
|
|
54
|
+
exports.fetchSubaccountDebank = fetchSubaccountDebank;
|
|
55
|
+
/**
|
|
56
|
+
* Fetch subaccount health factor for a given subaccount address
|
|
57
|
+
*/
|
|
58
|
+
const fetchSubaccountHeathFactor = async (address, augustKey, headers) => {
|
|
59
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.health_factor(address), {
|
|
60
|
+
headers,
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
63
|
+
throw new Error(`Failed to fetch subaccount health factor: ${response.statusText || 'Unknown error'}`);
|
|
64
|
+
}
|
|
65
|
+
return response.json();
|
|
66
|
+
};
|
|
67
|
+
exports.fetchSubaccountHeathFactor = fetchSubaccountHeathFactor;
|
|
68
|
+
/**
|
|
69
|
+
* Fetch subaccount loans details
|
|
70
|
+
*/
|
|
71
|
+
const fetchSubaccountLoans = async (payload, augustKey, headers) => {
|
|
72
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.loans(payload.address, payload.side, payload.active), {
|
|
73
|
+
headers,
|
|
74
|
+
});
|
|
75
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
76
|
+
throw new Error(`Failed to fetch subaccount loans: ${response.statusText || 'Unknown error'}`);
|
|
77
|
+
}
|
|
78
|
+
return response.json();
|
|
79
|
+
};
|
|
80
|
+
exports.fetchSubaccountLoans = fetchSubaccountLoans;
|
|
81
|
+
/**
|
|
82
|
+
* Fetch the subaccount CeFi positions
|
|
83
|
+
*/
|
|
84
|
+
const fetchSubaccountCefiPositions = async (address, augustKey, headers) => {
|
|
85
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.cefi(address), {
|
|
86
|
+
headers,
|
|
87
|
+
});
|
|
88
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
89
|
+
throw new Error(`Failed to fetch subaccount CeFi positions: ${response.statusText || 'Unknown error'}`);
|
|
90
|
+
}
|
|
91
|
+
return response.json();
|
|
92
|
+
};
|
|
93
|
+
exports.fetchSubaccountCefiPositions = fetchSubaccountCefiPositions;
|
|
94
|
+
/**
|
|
95
|
+
* Fetch the subaccount OTC positions
|
|
96
|
+
*/
|
|
97
|
+
const fetchSubaccountOtcPositions = async (address, augustKey, headers) => {
|
|
98
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.otc_positions(address), {
|
|
99
|
+
headers,
|
|
100
|
+
});
|
|
101
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
102
|
+
throw new Error(`Failed to fetch subaccount OTC positions: ${response.statusText || 'Unknown error'}`);
|
|
103
|
+
}
|
|
104
|
+
return response.json();
|
|
105
|
+
};
|
|
106
|
+
exports.fetchSubaccountOtcPositions = fetchSubaccountOtcPositions;
|
|
107
|
+
/**
|
|
108
|
+
* Fetch the subaccount summary view
|
|
109
|
+
*/
|
|
110
|
+
const fetchSubaccountSummary = async (address, augustKey, headers) => {
|
|
111
|
+
const response = await (0, core_1.fetchAugustWithKey)(augustKey, core_1.WEBSERVER_ENDPOINTS.subaccount.summary(address), {
|
|
112
|
+
headers,
|
|
113
|
+
});
|
|
114
|
+
if (!response.ok || typeof response.json !== 'function') {
|
|
115
|
+
throw new Error(`Failed to fetch subaccount summary: ${response.statusText || 'Unknown error'}`);
|
|
116
|
+
}
|
|
117
|
+
return response.json();
|
|
118
|
+
};
|
|
119
|
+
exports.fetchSubaccountSummary = fetchSubaccountSummary;
|
|
120
|
+
//# sourceMappingURL=fetcher.js.map
|