@augustdigital/sdk

中文文档
9.16.0发布于 2026/10/28MITTypeScriptCommonJS近 30 天下载 3.5万

JS SDK powering the August Digital ecosystem.

原始使用文档
文档目录31 节
  1. Installation
  2. Wagmi/Viem Support
  3. Quick Start
  4. App Name
  5. Origin-Code Attribution (SwapRouter)
  6. Architecture
  7. Key Concepts
  8. Multi-Chain Support
  9. Vault Versions
  10. Data Enrichment
  11. API Reference
  12. Vault Queries
  13. User Positions
  14. Points
  15. Write Operations (top-level)
  16. Cross-Chain (LayerZero)
  17. Utilities
  18. Sub-Accounts ( sdk.subAccountsModule )
  19. EVM Adapter ( sdk.evm )
  20. Solana Adapter ( sdk.solana )
  21. Stellar Adapter ( sdk.stellar )
  22. Sui Adapter ( sdk.sui )
  23. Code Conventions
  24. Naming Patterns
  25. Special Comment Tags
  26. Error Handling
  27. Environment Configuration
  28. Development
  29. Running Tests
  30. Building
  31. Support

August Digital SDK

TypeScript SDK for interacting with August Digital vaults across EVM, Solana, Stellar, and Sui chains.

Installation

npm install @augustdigital/sdk ethers
# or
pnpm add @augustdigital/sdk ethers
# or
yarn add @augustdigital/sdk ethers

Wagmi/Viem Support

The SDK supports both ethers and wagmi/viem signers. If you're using wagmi in your React app, also install viem:

npm install viem

The SDK automatically converts viem WalletClient to an ethers-compatible signer.

Quick Start

import AugustSDK from '@augustdigital/sdk';

const sdk = new AugustSDK({
  // Required: stable kebab-case slug identifying your application.
  appName: 'acme-trader',
  providers: {
    1: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY',
    42161: 'https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY',
    -1: 'https://api.mainnet-beta.solana.com', // Solana
  },
  keys: {
    august: 'YOUR_API_KEY', // Optional: vault reads, allocations and vault-linked sub-account reads work without it
  },
  monitoring: {
    env: 'DEV', // Optional: 'DEV' enables console logging (defaults to 'PROD')
  },
});

// Fetch all vaults
const vaults = await sdk.getVaults();

// Fetch a specific vault with loans and allocations
const vault = await sdk.getVault({
  vault: '0x...',
  options: { loans: true, allocations: true },
});

// Get user positions
const positions = await sdk.getVaultPositions({
  wallet: '0x...',
  showAllVaults: true,
});

App Name

appName is required on every AugustSDK constructor call. Pass a stable kebab-case slug identifying your application (e.g. 'acme-trader', 'my-defi-app'):

  • What it's used for. August Digital tags analytics events with app.name = <yourSlug> to attribute error spikes and prioritize bug fixes by consuming app.
  • What it is not. Not a secret, not a license key, not a display label. Pick a slug once and reuse it across deployments.
  • Constraints. 3–64 characters, only [a-zA-Z0-9._-]. The SDK throws synchronously from the constructor if the value is missing or invalid.
// Will throw — appName is required.
new AugustSDK({ providers: { /* ... */ } } as any);

// Will throw — spaces not allowed. Use 'acme-trader'.
new AugustSDK({ appName: 'Acme Trader', providers: { /* ... */ } });

// Correct.
new AugustSDK({ appName: 'acme-trader', providers: { /* ... */ } });

Origin-Code Attribution (SwapRouter)

An integrator with an origin (referral / fee-sharing) code registered on the SwapRouter sets it once on the SDK instance. Deposits made through the SDK then carry it on-chain:

const sdk = new AugustSDK({
  appName: 'acme-trader',
  providers: { 1: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY' },
  attribution: {
    originCode: '0x…', // bytes32 registered on the SwapRouter with addOrigin
    strictOrigin: false, // optional: true throws instead of falling back
  },
});

// Check the code before you ship it.
const { registered, originFeeBps, collector } = await sdk.getOriginInfo({
  chainId: 1,
  originCode: '0x…',
});
  • Ethereum mainnet only. The instance code is sent on chain 1 (ORIGIN_ATTRIBUTION_CHAINS) and on no other chain, even where a SwapRouter is configured.

  • Where it applies. vaultDeposit sends a deposit through SwapRouter.deposit with the code when sdk.evm.getDepositRoute() returns via: 'router': the vault is registered on the router, the vault accepts the asset as-is (its reference asset, or a Tokenized Vault V2 whitelisted asset — never swapped), the router whitelists the asset, the router is not paused, the deposit is not a permit, native-token or adapter deposit, and the code is registered. swapRouterDeposit, swapAndDeposit, depositViaSwapRouter and depositNativeViaSwapRouter send it too.

  • Precedence. An originCode passed to a router method wins, then the instance code, then the all-zero sentinel (no origin fee). Pass the zero sentinel to opt one call out.

  • Fallback. When the code cannot be applied — it is not registered, the chain is not mainnet, the router is paused (router-paused, checked with a 15-second cache) or does not whitelist the asset, the vault does not accept it or is not registered on the router, or it is a permit, native-token or adapter deposit — vaultDeposit takes the vault's native path and logs vaultDeposit:attribution-skipped with the reason (Sentry tag sdk.attribution.origin=skipped). The router methods send the zero sentinel for an unregistered instance code and log <method>:attribution-skipped. With strictOrigin: true an unregistered instance code throws AugustValidationError before any approval instead; a paused router falls back to native even then. An originCode passed to a router method that is not registered always throws AugustValidationError before any approval. While the router is paused, the router methods throw AugustSDKError (context.reason: 'router-paused') before any approval.

  • Approve route.spender, not the vault. A routed deposit is pulled by the SwapRouter. vaultDeposit and approve handle this; if you send approvals yourself, read the spender first:

    const route = await sdk.evm.getDepositRoute({ target: vault, depositAsset: usdc });
    // route.spender is the SwapRouter when route.via === 'router', else the vault (or adapter wrapper)
    
  • Gas. Measured on a mainnet fork (repeat 1,000 USDC deposits into Core USDC): direct deposit 102,067 gas; router with a 0% code 161,744 (+59.7k); router with a 1% code 173,135 (+71.1k). A routed deposit also needs a one-time approval of the router per token.

  • Zero-fee codes. A code registered with a 0 bps fee is valid for attribution only, but the router emits no OriginFeeApplied event for it. Its deposits are attributable only from the transaction calldata and SDK telemetry.

  • Process-global. attribution is process-global: the last AugustSDK constructed wins, and one constructed without attribution clears it. Run one attribution configuration per process.

Architecture

src.ts/
├── main.ts              # Main SDK class (AugustSDK)
├── core/                # Base utilities
│   ├── base.class.ts    # Base SDK functionality
│   ├── fetcher.ts       # API client with retry logic
│   └── web3.helpers.ts  # Blockchain utilities
├── adapters/            # Chain-specific implementations
│   ├── evm/             # EVM adapter (approve, deposit, redeem, read helpers)
│   ├── solana/          # Solana program adapters
│   ├── stellar/         # Stellar vault adapters
│   └── sui/             # Sui (Ember) vault adapters
├── evm/                 # EVM cross-chain (LayerZero OVault)
├── modules/             # Feature modules
│   ├── vaults/          # Vault read operations
│   ├── sub-accounts/    # Sub-account queries
│   └── api/             # August backend API integration
├── services/            # External service integrations
│   ├── debank/          # DeFi allocation data
│   ├── coingecko/       # Token pricing
│   └── subgraph/        # Historical transaction data
└── types/               # TypeScript interfaces

Key Concepts

Multi-Chain Support

  • EVM Chains: Ethereum, Arbitrum, Base, BSC, Avalanche, and more — wagmi/viem and ethers signers supported
  • Solana: Native Solana program support with full vault functionality
  • Stellar: Stellar vault deposit, redeem, and position queries
  • Sui: Ember vault read operations
  • Unified interface across all chains

Vault Versions

  • evm-0/evm-1: Legacy vault contracts
  • evm-2: Current EVM vault architecture (separate receipt tokens)
  • sol-0: Solana program-based vaults
  • stellar-0: Stellar-based vaults

Data Enrichment

All vault queries support optional enrichment:

  • loans: Include active loan data
  • allocations: DeFi/CeFi/OTC position breakdowns
  • wallet: User-specific position data

API Reference

Vault Queries

MethodDescription
getVaults(options?)Fetch all vaults across chains
getVault({ vault, chainId?, options? })Get single vault details
getVaultLoans({ vault, chainId? })Fetch active loans
getVaultAllocations({ vault, chainId? })Get allocation breakdown
getVaultHistoricalTimeseries({ vault, chainId? })Historical APY and TVL timeseries
getVaultApy({ vault, historical? })@deprecated — use getVaultHistoricalTimeseries
getVaultTvl({ vault, historical? })Current/historical TVL
getVaultAnnualizedApy({ vault })Annualized APY for a vault
getVaultSummary({ vault })Aggregated vault summary
getVaultPnl({ vault, chainId? })Vault-level PnL
getVaultUnrealizedPnlHistory({ vault, chainId?, ... })Unrealized PnL timeseries
getLatestUnrealizedPnl()Latest unrealized PnL snapshot across all vaults
getYieldLastRealizedOn({ vault, chainId? })Timestamp of last yield realization
getTotalDeposited(options?)Total deposited across vaults

User Positions

MethodDescription
getVaultPositions({ wallet?, vault?, chainId? })User vault positions
getVaultAvailableRedemptions({ vault, wallet?, chainId, verbose? })Claimable redemptions
getVaultRedemptionHistory({ vault, wallet?, chainId? })Historical redemptions
getVaultUserHistory({ wallet, vault?, chainId? })Transaction history
getVaultUserTransfers({ wallet, vault?, chainId? })Transfer history
getVaultUserLifetimePnl({ wallet, vault?, chainId? })Lifetime PnL for a wallet
getVaultStakingPositions({ wallet, chainId })Staking positions
getVaultBorrowerHealthFactor(props?)Borrower health factor
getVaultWithdrawals({ vault, chainId? })Pending withdrawals

Points

MethodDescription
getUserPoints(userAddress)Points balance for a wallet
registerUserForPoints({ wallet, referral? })Register a wallet for the points program
fetchPointsLeaderboard(params?)Points leaderboard

Write Operations (top-level)

MethodDescription
vaultDeposit(signer, options)Deposit into a vault
previewRedemption(props)Preview redemption output before broadcasting

Cross-Chain (LayerZero)

MethodDescription
getLayerZeroDeposits({ wallet?, chainId? })LayerZero deposit history
getLayerZeroRedeems(props?)LayerZero redemption history

Utilities

MethodDescription
getPrice(symbol)Token price in USD
switchNetwork(chainId)Change active chain
updateWallet(address)Set active wallet for tracking

Sub-Accounts (sdk.subAccountsModule)

MethodDescription
getSubaccountHealthFactor(address)Health factor for a sub-account
getSubaccountLoans(address)Active loans for a sub-account
getSubaccountCefiPositions(address)CeFi positions
getSubaccountOtcPositions(address)OTC positions
getSubaccountSummary(address)Aggregated sub-account summary

EVM Adapter (sdk.evm)

Set a signer before calling write methods:

// ethers
import { JsonRpcProvider, Wallet } from 'ethers';
const wallet = new Wallet(process.env.PRIVATE_KEY!, new JsonRpcProvider(rpcUrl));
sdk.evm.setSigner(wallet);

// wagmi/viem (browser)
import { useWalletClient } from 'wagmi';
const { data: walletClient } = useWalletClient();
if (walletClient) sdk.evm.setSigner(walletClient);

Write methods:

MethodDescription
vaultApprove(options)Approve token spend for a vault
approve(options)Generic ERC-20 approve
vaultDeposit(options)Deposit assets into a vault
vaultRequestRedeem(options)Request a withdrawal/redemption
vaultRedeem(signer, options)Claim an available redemption
depositNative(options)Deposit native tokens (ETH, etc.)
swapAndDeposit(options)Swap and deposit in one call
depositViaSwapRouter(options)Deposit via the swap router
depositNativeViaSwapRouter(options)Deposit native via the swap router

Read helpers (return raw bigint):

MethodDescription
previewDeposit(options)Shares minted for a deposit amount
previewRedeem(options)Assets returned for a share amount
allowance(options)ERC-20 allowance granted to the vault
balanceOf(options)ERC-20 balance for any token/owner
maxDeposit(options)Maximum deposit accepted by the vault
vaultAllowance(options)Vault-specific allowance check
getDeposited(options)Current deposited balance
getRemainingAllocations(options)Remaining allocation capacity
isWhitelisted(options)Check whitelist status

Solana Adapter (sdk.solana)

MethodDescription
getVaultState(...)Vault state from the Solana program
getVaultStateReadOnly(...)Read-only vault state
getToken(mintAddress)SPL token info
getTokenSymbol(mintAddress)Token symbol
fetchUserTokenBalance(publicKey, mint)User SPL token balance
fetchUserShareBalance(publicKey, vault)User share balance
fetchUserShareBalanceRaw(publicKey, vault)Raw share balance (bigint)

Stellar Adapter (sdk.stellar)

MethodDescription
vaultDeposit(options)Deposit into a Stellar vault
vaultRedeem(options)Redeem from a Stellar vault
submitTransaction(signedXdr)Submit a signed XDR transaction
getUserPosition(options)User position in a Stellar vault
convertToShares(options)Convert an asset amount to shares

Sui Adapter (sdk.sui)

MethodDescription
getEmberVaults()List all Ember (Sui) vaults
getEmberTVL(limit?)Total value locked across Ember vaults

Code Conventions

Naming Patterns

  • Interfaces: Prefixed with I (e.g., IVault, IVaultLoan)
  • ABIs: Prefixed with ABI_ (e.g., ABI_LENDING_POOL_V2)
  • Types: Descriptive names (e.g., IAddress, IChainId)

Special Comment Tags

Search the codebase for these to find important areas:

  • @todo: Planned improvements or missing features
  • @hardcoded: Hardcoded values that may need configuration
  • @solana: Solana-specific logic or notes

Error Handling

Every public method throws typed errors that subclass AugustSDKError:

import { AugustValidationError, AugustTimeoutError, AugustSDKError } from '@augustdigital/sdk';

try {
  await sdk.evm.vaultDeposit({ target: '0x...', wallet: owner, amount: '1' });
} catch (err) {
  if (err instanceof AugustValidationError) showFormError(err.message);
  else if (err instanceof AugustTimeoutError) scheduleRetry(err.timeoutMs);
  else if (err instanceof AugustSDKError) reportError(err.code, err.cause);
  else throw err;
}
  • Automatic retry with exponential backoff for network errors
  • 90-second request timeout (configurable via REQUEST_TIMEOUT_MS)
  • Correlation IDs in errors for debugging

Environment Configuration

// Development mode — enables console logging
const sdk = new AugustSDK({ appName: 'my-app', providers: { /* ... */ }, monitoring: { env: 'DEV' } });

// Production mode — default, no console logs
const sdk = new AugustSDK({ appName: 'my-app', providers: { /* ... */ } });

Development

Running Tests

pnpm test

Building

pnpm build

Support

版本与发布记录

@augustdigital/sdk 共发布 534 个版本,首次发布于 2024/06/28;过去 12 个月发布了 172 个版本。

版本发布日期距今
9.16.0latest2026/10/2810 天前
9.15.02026/10/2711 天前
9.14.02026/10/2415 天前
9.13.32026/10/1523 天前
9.13.22026/10/1524 天前
9.13.12026/10/1425 天前

其他发布通道:alpha-release → 4.3.2-alpha3,4.4.3test → 4.4.3-alpha,betatest → 4.7.2-beta,testing → 4.7.3-alpha,alpha-test-rwa → 4.24.3-alpha.2,alpha-test-rwa-2 → 4.24.3-alpha.3。

关于 @augustdigital/sdk 的常见问题

@augustdigital/sdk 是什么?

JS SDK powering the August Digital ecosystem.

如何安装 @augustdigital/sdk?

在项目目录运行 npm install @augustdigital/sdk,或使用 pnpm add / yarn add / bun add。

@augustdigital/sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@augustdigital/sdk 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@augustdigital/sdk 可以商用吗?

@augustdigital/sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@augustdigital/sdk 的下载量有多少?

根据 npm 官方下载统计,@augustdigital/sdk 在 2026/10/07 – 2026/11/05 这 30 天内被下载 34,708 次,日均约 1,157 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@augustdigital/sdk 还在维护吗?

最新版本 9.16.0 发布于 2026/10/28(10 天前);至今共发布 534 个版本,其中过去 12 个月发布了 172 个;首次发布于 2024/06/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。