@augustdigital/sdk 8.5.0 → 8.6.1
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/adapters/evm/index.d.ts +4 -4
- package/lib/adapters/evm/index.js +2 -0
- package/lib/adapters/solana/constants.d.ts +1 -1
- package/lib/adapters/solana/getters.d.ts +1 -1
- package/lib/adapters/solana/index.d.ts +4 -4
- package/lib/adapters/solana/index.js +4 -0
- package/lib/adapters/solana/types.d.ts +1 -1
- package/lib/adapters/solana/utils.d.ts +3 -3
- package/lib/adapters/solana/vault.actions.d.ts +4 -4
- package/lib/adapters/stellar/actions.d.ts +1 -1
- package/lib/adapters/stellar/index.d.ts +24 -2
- package/lib/adapters/stellar/index.js +25 -2
- package/lib/adapters/stellar/soroban.d.ts +1 -1
- package/lib/adapters/stellar/soroban.js +1 -1
- package/lib/adapters/stellar/submit.d.ts +20 -3
- package/lib/adapters/stellar/submit.js +74 -8
- package/lib/adapters/sui/getters.d.ts +1 -1
- package/lib/adapters/sui/index.d.ts +1 -1
- package/lib/adapters/sui/index.js +2 -0
- package/lib/adapters/sui/transformer.d.ts +2 -2
- package/lib/adapters/sui/transformer.js +1 -0
- package/lib/adapters/sui/types.d.ts +1 -1
- package/lib/core/analytics/instrumentation.js +7 -11
- package/lib/core/analytics/sentry-runtime.js +1 -1
- package/lib/core/analytics/sentry.d.ts +3 -3
- package/lib/core/analytics/sentry.js +31 -5
- package/lib/core/analytics/types.d.ts +1 -1
- package/lib/core/analytics/user-identity.d.ts +2 -2
- package/lib/core/analytics/user-identity.js +1 -1
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/base.class.d.ts +3 -3
- package/lib/core/base.class.js +10 -4
- package/lib/core/constants/adapters.d.ts +1 -1
- package/lib/core/constants/core.d.ts +2 -0
- package/lib/core/constants/core.js +6 -0
- package/lib/core/constants/swap-router.d.ts +37 -1
- package/lib/core/constants/swap-router.js +41 -1
- package/lib/core/constants/vaults.d.ts +1 -1
- package/lib/core/constants/web3.d.ts +1 -1
- package/lib/core/constants/web3.js +0 -3
- package/lib/core/errors/index.d.ts +2 -2
- package/lib/core/errors/index.js +9 -0
- package/lib/core/fetcher.d.ts +39 -39
- package/lib/core/fetcher.js +75 -57
- package/lib/core/helpers/adapters.d.ts +1 -1
- package/lib/core/helpers/chain-error.d.ts +66 -0
- package/lib/core/helpers/chain-error.js +174 -0
- package/lib/core/helpers/core.d.ts +21 -18
- package/lib/core/helpers/core.js +22 -20
- package/lib/core/helpers/explorer-link.d.ts +1 -1
- package/lib/core/helpers/signer.d.ts +1 -1
- package/lib/core/helpers/swap-router.d.ts +1 -1
- package/lib/core/helpers/vault-version.d.ts +1 -1
- package/lib/core/helpers/vaults.d.ts +1 -1
- package/lib/core/helpers/web3.d.ts +2 -2
- package/lib/core/helpers/web3.js +9 -9
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.js +1 -0
- package/lib/core/vault-metadata.d.ts +1 -1
- package/lib/core/version-check.js +1 -1
- package/lib/evm/methods/crossChainVault.js +1 -1
- package/lib/evm/types/crossChain.js +1 -1
- package/lib/main.d.ts +1 -1
- package/lib/main.js +7 -0
- package/lib/modules/sub-accounts/fetcher.d.ts +2 -2
- package/lib/modules/sub-accounts/main.d.ts +2 -2
- package/lib/modules/sub-accounts/main.js +1 -1
- package/lib/modules/sub-accounts/utils.d.ts +1 -1
- package/lib/modules/vaults/adapter.helpers.d.ts +3 -3
- package/lib/modules/vaults/fetcher.d.ts +25 -0
- package/lib/modules/vaults/fetcher.js +51 -1
- package/lib/modules/vaults/getters.d.ts +50 -50
- package/lib/modules/vaults/getters.js +68 -67
- package/lib/modules/vaults/main.js +3 -1
- package/lib/modules/vaults/read.actions.d.ts +2 -2
- package/lib/modules/vaults/read.actions.js +26 -12
- package/lib/modules/vaults/utils/call-data-decoder.d.ts +1 -1
- package/lib/modules/vaults/utils.d.ts +19 -3
- package/lib/modules/vaults/utils.js +39 -6
- package/lib/modules/vaults/write.actions.js +73 -7
- package/lib/polyfills.js +3 -3
- package/lib/sdk.d.ts +1409 -1198
- package/lib/services/coingecko/fetcher.d.ts +10 -9
- package/lib/services/coingecko/fetcher.js +22 -18
- package/lib/services/debank/fetcher.d.ts +1 -1
- package/lib/services/debank/utils.d.ts +1 -1
- package/lib/services/debank/utils.js +1 -1
- package/lib/services/layerzero/deposits.d.ts +1 -1
- package/lib/services/layerzero/redeems.d.ts +1 -1
- package/lib/services/octavfi/fetcher.d.ts +1 -1
- package/lib/services/octavfi/types.d.ts +1 -1
- package/lib/services/octavfi/utils.d.ts +2 -2
- package/lib/services/subgraph/fetcher.js +1 -1
- package/lib/services/subgraph/vaults.js +86 -3
- package/lib/services/swap-quotes/index.d.ts +9 -0
- package/lib/services/swap-quotes/index.js +2 -1
- package/lib/services/swap-quotes/paraswap.d.ts +8 -0
- package/lib/services/swap-quotes/paraswap.js +8 -0
- package/lib/types/pools.d.ts +2 -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/vaults.d.ts +26 -0
- package/lib/types/web3.d.ts +1 -1
- package/lib/types/webserver.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# August Digital SDK
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for interacting with August Digital vaults across EVM and
|
|
3
|
+
TypeScript SDK for interacting with August Digital vaults across EVM, Solana, Stellar, and Sui chains.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -20,17 +20,15 @@ The SDK supports both ethers and wagmi/viem signers. If you're using wagmi in yo
|
|
|
20
20
|
npm install viem
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
The SDK
|
|
23
|
+
The SDK automatically converts viem `WalletClient` to an ethers-compatible signer.
|
|
24
24
|
|
|
25
25
|
## Quick Start
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import
|
|
28
|
+
import AugustSDK from '@augustdigital/sdk';
|
|
29
29
|
|
|
30
|
-
// Initialize with RPC providers
|
|
31
30
|
const sdk = new AugustSDK({
|
|
32
|
-
// Required:
|
|
33
|
-
// See "App Name" below for what this is used for.
|
|
31
|
+
// Required: stable kebab-case slug identifying your application.
|
|
34
32
|
appName: 'acme-trader',
|
|
35
33
|
providers: {
|
|
36
34
|
1: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY',
|
|
@@ -38,7 +36,7 @@ const sdk = new AugustSDK({
|
|
|
38
36
|
-1: 'https://api.mainnet-beta.solana.com', // Solana
|
|
39
37
|
},
|
|
40
38
|
keys: {
|
|
41
|
-
august: 'YOUR_API_KEY', // Optional: required for allocations, health factors, and
|
|
39
|
+
august: 'YOUR_API_KEY', // Optional: required for allocations, health factors, and sub-account operations
|
|
42
40
|
},
|
|
43
41
|
monitoring: {
|
|
44
42
|
env: 'DEV', // Optional: 'DEV' enables console logging (defaults to 'PROD')
|
|
@@ -48,10 +46,10 @@ const sdk = new AugustSDK({
|
|
|
48
46
|
// Fetch all vaults
|
|
49
47
|
const vaults = await sdk.getVaults();
|
|
50
48
|
|
|
51
|
-
// Fetch specific vault with loans and allocations
|
|
49
|
+
// Fetch a specific vault with loans and allocations
|
|
52
50
|
const vault = await sdk.getVault({
|
|
53
51
|
vault: '0x...',
|
|
54
|
-
options: { loans: true, allocations: true }
|
|
52
|
+
options: { loans: true, allocations: true },
|
|
55
53
|
});
|
|
56
54
|
|
|
57
55
|
// Get user positions
|
|
@@ -63,57 +61,25 @@ const positions = await sdk.getVaultPositions({
|
|
|
63
61
|
|
|
64
62
|
### App Name
|
|
65
63
|
|
|
66
|
-
`appName` is required on every `AugustSDK` constructor call. Pass a
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
auth token, and despite the friendly name it's **not a display
|
|
76
|
-
label**. It's a self-issued identifier — pick a slug once and reuse
|
|
77
|
-
it across deployments.
|
|
78
|
-
- **Constraints.** 3–64 characters, only `[a-zA-Z0-9._-]`. Use a slug
|
|
79
|
-
like `'acme-trader'`, **not** a display name like `'Acme Trader'`
|
|
80
|
-
(spaces and special characters will throw). The SDK throws
|
|
81
|
-
synchronously from the constructor if the value is missing or
|
|
82
|
-
invalid, so a wrong value fails loudly at integration time rather
|
|
83
|
-
than silently in production.
|
|
64
|
+
`appName` is required on every `AugustSDK` constructor call. Pass a stable kebab-case slug
|
|
65
|
+
identifying your application (e.g. `'acme-trader'`, `'my-defi-app'`):
|
|
66
|
+
|
|
67
|
+
- **What it's used for.** August Digital tags analytics events with `app.name = <yourSlug>` to
|
|
68
|
+
attribute error spikes and prioritize bug fixes by consuming app.
|
|
69
|
+
- **What it is not.** Not a secret, not a license key, not a display label. Pick a slug once
|
|
70
|
+
and reuse it across deployments.
|
|
71
|
+
- **Constraints.** 3–64 characters, only `[a-zA-Z0-9._-]`. The SDK throws synchronously from
|
|
72
|
+
the constructor if the value is missing or invalid.
|
|
84
73
|
|
|
85
74
|
```typescript
|
|
86
75
|
// Will throw — appName is required.
|
|
87
|
-
new AugustSDK({
|
|
88
|
-
providers: {
|
|
89
|
-
/* ... */
|
|
90
|
-
},
|
|
91
|
-
keys: {
|
|
92
|
-
/* ... */
|
|
93
|
-
},
|
|
94
|
-
} as any);
|
|
76
|
+
new AugustSDK({ providers: { /* ... */ } } as any);
|
|
95
77
|
|
|
96
|
-
// Will throw —
|
|
97
|
-
new AugustSDK({
|
|
98
|
-
appName: 'Acme Trader',
|
|
99
|
-
providers: {
|
|
100
|
-
/* ... */
|
|
101
|
-
},
|
|
102
|
-
keys: {
|
|
103
|
-
/* ... */
|
|
104
|
-
},
|
|
105
|
-
});
|
|
78
|
+
// Will throw — spaces not allowed. Use 'acme-trader'.
|
|
79
|
+
new AugustSDK({ appName: 'Acme Trader', providers: { /* ... */ } });
|
|
106
80
|
|
|
107
81
|
// Correct.
|
|
108
|
-
new AugustSDK({
|
|
109
|
-
appName: 'acme-trader',
|
|
110
|
-
providers: {
|
|
111
|
-
/* ... */
|
|
112
|
-
},
|
|
113
|
-
keys: {
|
|
114
|
-
/* ... */
|
|
115
|
-
},
|
|
116
|
-
});
|
|
82
|
+
new AugustSDK({ appName: 'acme-trader', providers: { /* ... */ } });
|
|
117
83
|
```
|
|
118
84
|
|
|
119
85
|
## Architecture
|
|
@@ -126,13 +92,15 @@ src.ts/
|
|
|
126
92
|
│ ├── fetcher.ts # API client with retry logic
|
|
127
93
|
│ └── web3.helpers.ts # Blockchain utilities
|
|
128
94
|
├── adapters/ # Chain-specific implementations
|
|
129
|
-
│ ├── evm/ # EVM
|
|
130
|
-
│
|
|
95
|
+
│ ├── evm/ # EVM adapter (approve, deposit, redeem, read helpers)
|
|
96
|
+
│ ├── solana/ # Solana program adapters
|
|
97
|
+
│ ├── stellar/ # Stellar vault adapters
|
|
98
|
+
│ └── sui/ # Sui (Ember) vault adapters
|
|
99
|
+
├── evm/ # EVM cross-chain (LayerZero OVault)
|
|
131
100
|
├── modules/ # Feature modules
|
|
132
|
-
│
|
|
133
|
-
│
|
|
134
|
-
│
|
|
135
|
-
│ └── utils.ts # Helper utilities
|
|
101
|
+
│ ├── vaults/ # Vault read operations
|
|
102
|
+
│ ├── sub-accounts/ # Sub-account queries
|
|
103
|
+
│ └── api/ # August backend API integration
|
|
136
104
|
├── services/ # External service integrations
|
|
137
105
|
│ ├── debank/ # DeFi allocation data
|
|
138
106
|
│ ├── coingecko/ # Token pricing
|
|
@@ -144,8 +112,10 @@ src.ts/
|
|
|
144
112
|
|
|
145
113
|
### Multi-Chain Support
|
|
146
114
|
|
|
147
|
-
- **EVM Chains**: Ethereum, Arbitrum, Base, BSC, Avalanche
|
|
148
|
-
- **Solana**: Native Solana program support
|
|
115
|
+
- **EVM Chains**: Ethereum, Arbitrum, Base, BSC, Avalanche, and more — `wagmi/viem` and `ethers` signers supported
|
|
116
|
+
- **Solana**: Native Solana program support with full vault functionality
|
|
117
|
+
- **Stellar**: Stellar vault deposit, redeem, and position queries
|
|
118
|
+
- **Sui**: Ember vault read operations
|
|
149
119
|
- Unified interface across all chains
|
|
150
120
|
|
|
151
121
|
### Vault Versions
|
|
@@ -153,6 +123,7 @@ src.ts/
|
|
|
153
123
|
- `evm-0/evm-1`: Legacy vault contracts
|
|
154
124
|
- `evm-2`: Current EVM vault architecture (separate receipt tokens)
|
|
155
125
|
- `sol-0`: Solana program-based vaults
|
|
126
|
+
- `stellar-0`: Stellar-based vaults
|
|
156
127
|
|
|
157
128
|
### Data Enrichment
|
|
158
129
|
|
|
@@ -162,6 +133,154 @@ All vault queries support optional enrichment:
|
|
|
162
133
|
- `allocations`: DeFi/CeFi/OTC position breakdowns
|
|
163
134
|
- `wallet`: User-specific position data
|
|
164
135
|
|
|
136
|
+
## API Reference
|
|
137
|
+
|
|
138
|
+
### Vault Queries
|
|
139
|
+
|
|
140
|
+
| Method | Description |
|
|
141
|
+
| --- | --- |
|
|
142
|
+
| `getVaults(options?)` | Fetch all vaults across chains |
|
|
143
|
+
| `getVault({ vault, chainId?, options? })` | Get single vault details |
|
|
144
|
+
| `getVaultLoans({ vault, chainId? })` | Fetch active loans |
|
|
145
|
+
| `getVaultAllocations({ vault, chainId? })` | Get allocation breakdown |
|
|
146
|
+
| `getVaultHistoricalTimeseries({ vault, chainId? })` | Historical APY and TVL timeseries |
|
|
147
|
+
| `getVaultApy({ vault, historical? })` | **@deprecated** — use `getVaultHistoricalTimeseries` |
|
|
148
|
+
| `getVaultTvl({ vault, historical? })` | Current/historical TVL |
|
|
149
|
+
| `getVaultAnnualizedApy({ vault })` | Annualized APY for a vault |
|
|
150
|
+
| `getVaultSummary({ vault })` | Aggregated vault summary |
|
|
151
|
+
| `getVaultPnl({ vault, chainId? })` | Vault-level PnL |
|
|
152
|
+
| `getVaultUnrealizedPnlHistory({ vault, chainId?, ... })` | Unrealized PnL timeseries |
|
|
153
|
+
| `getLatestUnrealizedPnl()` | Latest unrealized PnL snapshot across all vaults |
|
|
154
|
+
| `getYieldLastRealizedOn({ vault, chainId? })` | Timestamp of last yield realization |
|
|
155
|
+
| `getTotalDeposited(options?)` | Total deposited across vaults |
|
|
156
|
+
|
|
157
|
+
### User Positions
|
|
158
|
+
|
|
159
|
+
| Method | Description |
|
|
160
|
+
| --- | --- |
|
|
161
|
+
| `getVaultPositions({ wallet?, vault?, chainId? })` | User vault positions |
|
|
162
|
+
| `getVaultAvailableRedemptions({ vault, wallet?, chainId, verbose? })` | Claimable redemptions |
|
|
163
|
+
| `getVaultRedemptionHistory({ vault, wallet?, chainId? })` | Historical redemptions |
|
|
164
|
+
| `getVaultUserHistory({ wallet, vault?, chainId? })` | Transaction history |
|
|
165
|
+
| `getVaultUserTransfers({ wallet, vault?, chainId? })` | Transfer history |
|
|
166
|
+
| `getVaultUserLifetimePnl({ wallet, vault?, chainId? })` | Lifetime PnL for a wallet |
|
|
167
|
+
| `getVaultStakingPositions({ wallet, chainId })` | Staking positions |
|
|
168
|
+
| `getVaultBorrowerHealthFactor(props?)` | Borrower health factor |
|
|
169
|
+
| `getVaultWithdrawals({ vault, chainId? })` | Pending withdrawals |
|
|
170
|
+
|
|
171
|
+
### Points
|
|
172
|
+
|
|
173
|
+
| Method | Description |
|
|
174
|
+
| --- | --- |
|
|
175
|
+
| `getUserPoints(userAddress)` | Points balance for a wallet |
|
|
176
|
+
| `registerUserForPoints({ wallet, referral? })` | Register a wallet for the points program |
|
|
177
|
+
| `fetchPointsLeaderboard(params?)` | Points leaderboard |
|
|
178
|
+
|
|
179
|
+
### Write Operations (top-level)
|
|
180
|
+
|
|
181
|
+
| Method | Description |
|
|
182
|
+
| --- | --- |
|
|
183
|
+
| `vaultDeposit(signer, options)` | Deposit into a vault |
|
|
184
|
+
| `previewRedemption(props)` | Preview redemption output before broadcasting |
|
|
185
|
+
|
|
186
|
+
### Cross-Chain (LayerZero)
|
|
187
|
+
|
|
188
|
+
| Method | Description |
|
|
189
|
+
| --- | --- |
|
|
190
|
+
| `getLayerZeroDeposits({ wallet?, chainId? })` | LayerZero deposit history |
|
|
191
|
+
| `getLayerZeroRedeems(props?)` | LayerZero redemption history |
|
|
192
|
+
|
|
193
|
+
### Utilities
|
|
194
|
+
|
|
195
|
+
| Method | Description |
|
|
196
|
+
| --- | --- |
|
|
197
|
+
| `getPrice(symbol)` | Token price in USD |
|
|
198
|
+
| `switchNetwork(chainId)` | Change active chain |
|
|
199
|
+
| `updateWallet(address)` | Set active wallet for tracking |
|
|
200
|
+
|
|
201
|
+
### Sub-Accounts (`sdk.subAccountsModule`)
|
|
202
|
+
|
|
203
|
+
| Method | Description |
|
|
204
|
+
| --- | --- |
|
|
205
|
+
| `getSubaccountHealthFactor(address)` | Health factor for a sub-account |
|
|
206
|
+
| `getSubaccountLoans(address)` | Active loans for a sub-account |
|
|
207
|
+
| `getSubaccountCefiPositions(address)` | CeFi positions |
|
|
208
|
+
| `getSubaccountOtcPositions(address)` | OTC positions |
|
|
209
|
+
| `getSubaccountSummary(address)` | Aggregated sub-account summary |
|
|
210
|
+
|
|
211
|
+
### EVM Adapter (`sdk.evm`)
|
|
212
|
+
|
|
213
|
+
Set a signer before calling write methods:
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
// ethers
|
|
217
|
+
import { JsonRpcProvider, Wallet } from 'ethers';
|
|
218
|
+
const wallet = new Wallet(process.env.PRIVATE_KEY!, new JsonRpcProvider(rpcUrl));
|
|
219
|
+
sdk.evm.setSigner(wallet);
|
|
220
|
+
|
|
221
|
+
// wagmi/viem (browser)
|
|
222
|
+
import { useWalletClient } from 'wagmi';
|
|
223
|
+
const { data: walletClient } = useWalletClient();
|
|
224
|
+
if (walletClient) sdk.evm.setSigner(walletClient);
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Write methods:**
|
|
228
|
+
|
|
229
|
+
| Method | Description |
|
|
230
|
+
| --- | --- |
|
|
231
|
+
| `vaultApprove(options)` | Approve token spend for a vault |
|
|
232
|
+
| `approve(options)` | Generic ERC-20 approve |
|
|
233
|
+
| `vaultDeposit(options)` | Deposit assets into a vault |
|
|
234
|
+
| `vaultRequestRedeem(options)` | Request a withdrawal/redemption |
|
|
235
|
+
| `vaultRedeem(signer, options)` | Claim an available redemption |
|
|
236
|
+
| `depositNative(options)` | Deposit native tokens (ETH, etc.) |
|
|
237
|
+
| `swapAndDeposit(options)` | Swap and deposit in one call |
|
|
238
|
+
| `depositViaSwapRouter(options)` | Deposit via the swap router |
|
|
239
|
+
| `depositNativeViaSwapRouter(options)` | Deposit native via the swap router |
|
|
240
|
+
|
|
241
|
+
**Read helpers (return raw `bigint`):**
|
|
242
|
+
|
|
243
|
+
| Method | Description |
|
|
244
|
+
| --- | --- |
|
|
245
|
+
| `previewDeposit(options)` | Shares minted for a deposit amount |
|
|
246
|
+
| `previewRedeem(options)` | Assets returned for a share amount |
|
|
247
|
+
| `allowance(options)` | ERC-20 allowance granted to the vault |
|
|
248
|
+
| `balanceOf(options)` | ERC-20 balance for any token/owner |
|
|
249
|
+
| `maxDeposit(options)` | Maximum deposit accepted by the vault |
|
|
250
|
+
| `vaultAllowance(options)` | Vault-specific allowance check |
|
|
251
|
+
| `getDeposited(options)` | Current deposited balance |
|
|
252
|
+
| `getRemainingAllocations(options)` | Remaining allocation capacity |
|
|
253
|
+
| `isWhitelisted(options)` | Check whitelist status |
|
|
254
|
+
|
|
255
|
+
### Solana Adapter (`sdk.solana`)
|
|
256
|
+
|
|
257
|
+
| Method | Description |
|
|
258
|
+
| --- | --- |
|
|
259
|
+
| `getVaultState(...)` | Vault state from the Solana program |
|
|
260
|
+
| `getVaultStateReadOnly(...)` | Read-only vault state |
|
|
261
|
+
| `getToken(mintAddress)` | SPL token info |
|
|
262
|
+
| `getTokenSymbol(mintAddress)` | Token symbol |
|
|
263
|
+
| `fetchUserTokenBalance(publicKey, mint)` | User SPL token balance |
|
|
264
|
+
| `fetchUserShareBalance(publicKey, vault)` | User share balance |
|
|
265
|
+
| `fetchUserShareBalanceRaw(publicKey, vault)` | Raw share balance (bigint) |
|
|
266
|
+
|
|
267
|
+
### Stellar Adapter (`sdk.stellar`)
|
|
268
|
+
|
|
269
|
+
| Method | Description |
|
|
270
|
+
| --- | --- |
|
|
271
|
+
| `vaultDeposit(options)` | Deposit into a Stellar vault |
|
|
272
|
+
| `vaultRedeem(options)` | Redeem from a Stellar vault |
|
|
273
|
+
| `submitTransaction(signedXdr)` | Submit a signed XDR transaction |
|
|
274
|
+
| `getUserPosition(options)` | User position in a Stellar vault |
|
|
275
|
+
| `convertToShares(options)` | Convert an asset amount to shares |
|
|
276
|
+
|
|
277
|
+
### Sui Adapter (`sdk.sui`)
|
|
278
|
+
|
|
279
|
+
| Method | Description |
|
|
280
|
+
| --- | --- |
|
|
281
|
+
| `getEmberVaults()` | List all Ember (Sui) vaults |
|
|
282
|
+
| `getEmberTVL(limit?)` | Total value locked across Ember vaults |
|
|
283
|
+
|
|
165
284
|
## Code Conventions
|
|
166
285
|
|
|
167
286
|
### Naming Patterns
|
|
@@ -170,9 +289,9 @@ All vault queries support optional enrichment:
|
|
|
170
289
|
- **ABIs**: Prefixed with `ABI_` (e.g., `ABI_LENDING_POOL_V2`)
|
|
171
290
|
- **Types**: Descriptive names (e.g., `IAddress`, `IChainId`)
|
|
172
291
|
|
|
173
|
-
###
|
|
292
|
+
### Special Comment Tags
|
|
174
293
|
|
|
175
|
-
Search codebase for these
|
|
294
|
+
Search the codebase for these to find important areas:
|
|
176
295
|
|
|
177
296
|
- `@todo`: Planned improvements or missing features
|
|
178
297
|
- `@hardcoded`: Hardcoded values that may need configuration
|
|
@@ -180,61 +299,34 @@ Search codebase for these comments to find areas needing attention:
|
|
|
180
299
|
|
|
181
300
|
### Error Handling
|
|
182
301
|
|
|
183
|
-
|
|
184
|
-
- 90-second request timeout (configurable via `REQUEST_TIMEOUT_MS`)
|
|
185
|
-
- Correlation IDs logged for debugging failed requests
|
|
186
|
-
- Write actions throw errors instead of silent failures
|
|
187
|
-
|
|
188
|
-
### Environment Configuration
|
|
302
|
+
Every public method throws typed errors that subclass `AugustSDKError`:
|
|
189
303
|
|
|
190
304
|
```typescript
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
// Production mode (default - no console logs)
|
|
202
|
-
const prodSdk = new AugustSDK({
|
|
203
|
-
providers: {
|
|
204
|
-
/* ... */
|
|
205
|
-
},
|
|
206
|
-
// monitoring is optional - defaults to PROD
|
|
207
|
-
});
|
|
305
|
+
import { AugustValidationError, AugustTimeoutError, AugustSDKError } from '@augustdigital/sdk';
|
|
306
|
+
|
|
307
|
+
try {
|
|
308
|
+
await sdk.evm.vaultDeposit({ target: '0x...', wallet: owner, amount: '1' });
|
|
309
|
+
} catch (err) {
|
|
310
|
+
if (err instanceof AugustValidationError) showFormError(err.message);
|
|
311
|
+
else if (err instanceof AugustTimeoutError) scheduleRetry(err.timeoutMs);
|
|
312
|
+
else if (err instanceof AugustSDKError) reportError(err.code, err.cause);
|
|
313
|
+
else throw err;
|
|
314
|
+
}
|
|
208
315
|
```
|
|
209
316
|
|
|
210
|
-
-
|
|
211
|
-
-
|
|
212
|
-
|
|
213
|
-
## API Reference
|
|
214
|
-
|
|
215
|
-
### Main Methods
|
|
216
|
-
|
|
217
|
-
#### Vault Queries
|
|
218
|
-
|
|
219
|
-
- `getVaults(options?)`: Fetch all vaults across chains
|
|
220
|
-
- `getVault({ vault, chainId?, options? })`: Get single vault details
|
|
221
|
-
- `getVaultLoans({ vault, chainId })`: Fetch active loans
|
|
222
|
-
- `getVaultAllocations({ vault, chainId })`: Get allocation breakdown
|
|
223
|
-
- `getVaultApy({ vault, historical? })`: Current/historical APY
|
|
224
|
-
- `getVaultTvl({ vault, historical? })`: Current/historical TVL
|
|
225
|
-
|
|
226
|
-
#### User Positions
|
|
317
|
+
- Automatic retry with exponential backoff for network errors
|
|
318
|
+
- 90-second request timeout (configurable via `REQUEST_TIMEOUT_MS`)
|
|
319
|
+
- Correlation IDs in errors for debugging
|
|
227
320
|
|
|
228
|
-
|
|
229
|
-
- `getVaultAvailableRedemptions({ vault, wallet?, chainId, verbose?})`: Claimable redemptions
|
|
230
|
-
- `getVaultUserHistory({ wallet, vault?, chainId? })`: Transaction history
|
|
231
|
-
- `getVaultStakingPositions({ wallet, chainId })`: Staking positions
|
|
321
|
+
### Environment Configuration
|
|
232
322
|
|
|
233
|
-
|
|
323
|
+
```typescript
|
|
324
|
+
// Development mode — enables console logging
|
|
325
|
+
const sdk = new AugustSDK({ appName: 'my-app', providers: { /* ... */ }, monitoring: { env: 'DEV' } });
|
|
234
326
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
327
|
+
// Production mode — default, no console logs
|
|
328
|
+
const sdk = new AugustSDK({ appName: 'my-app', providers: { /* ... */ } });
|
|
329
|
+
```
|
|
238
330
|
|
|
239
331
|
## Development
|
|
240
332
|
|
|
@@ -250,10 +342,8 @@ pnpm test
|
|
|
250
342
|
pnpm build
|
|
251
343
|
```
|
|
252
344
|
|
|
253
|
-
### Type Checking
|
|
254
|
-
|
|
255
|
-
All exports are fully typed. Use TypeScript for best developer experience.
|
|
256
|
-
|
|
257
345
|
## Support
|
|
258
346
|
|
|
259
|
-
|
|
347
|
+
- **Issues**: [GitHub Issues](https://github.com/fractal-protocol/js-sdk/issues)
|
|
348
|
+
- **Documentation**: [docs.augustdigital.io](https://docs.augustdigital.io/developers/javascript-sdk)
|
|
349
|
+
- **Example App**: [starter.upshift.finance](https://starter.upshift.finance/)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { IContractWriteOptions, INativeDepositOptions, ApproveResult } from '../../modules/vaults/write.actions';
|
|
1
|
+
import { type IContractWriteOptions, type INativeDepositOptions, type ApproveResult } from '../../modules/vaults/write.actions';
|
|
2
2
|
import type { ISwapAndDepositOptions, ISwapRouterDirectDepositOptions, ISwapRouterNativeDepositOptions } from '../../types';
|
|
3
|
-
import { IPreviewDepositOptions, IPreviewRedeemOptions, IAllowanceOptions, IBalanceOfOptions, IMaxDepositOptions } from '../../modules/vaults/read.actions';
|
|
4
|
-
import { CompatibleSigner } from '../../core/helpers/signer';
|
|
5
|
-
import { IAddress } from '../../types';
|
|
3
|
+
import { type IPreviewDepositOptions, type IPreviewRedeemOptions, type IAllowanceOptions, type IBalanceOfOptions, type IMaxDepositOptions } from '../../modules/vaults/read.actions';
|
|
4
|
+
import { type CompatibleSigner } from '../../core/helpers/signer';
|
|
5
|
+
import type { IAddress } from '../../types';
|
|
6
6
|
export * from './getters';
|
|
7
7
|
/**
|
|
8
8
|
* EVM Adapter for August SDK
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
import * as SolanaConstants from './constants';
|
|
7
7
|
import * as SolanaGetters from './getters';
|
|
8
8
|
import * as SolanaActions from './vault.actions';
|
|
9
|
-
import { AnchorProvider, web3 } from '@coral-xyz/anchor';
|
|
10
|
-
import { Connection, PublicKey, Transaction } from '@solana/web3.js';
|
|
11
|
-
import { ISolanaNetwork, ISolanaRpcEndpoint } from './types';
|
|
12
|
-
import { SendTransactionOptions } from '@solana/wallet-adapter-base';
|
|
9
|
+
import type { AnchorProvider, web3 } from '@coral-xyz/anchor';
|
|
10
|
+
import { Connection, PublicKey, type Transaction } from '@solana/web3.js';
|
|
11
|
+
import type { ISolanaNetwork, ISolanaRpcEndpoint } from './types';
|
|
12
|
+
import type { SendTransactionOptions } from '@solana/wallet-adapter-base';
|
|
13
13
|
export declare const Solana: {
|
|
14
14
|
utils: {
|
|
15
15
|
getExplorerLink: ({ signature, type, network, }: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
1
|
+
import type { AnchorProvider } from '@coral-xyz/anchor';
|
|
2
2
|
import type { Connection, PublicKey } from '@solana/web3.js';
|
|
3
3
|
export type ISolanaRpcEndpoint = `https://${string}`;
|
|
4
4
|
export type ISolanaNetwork = 'devnet' | 'mainnet-beta' | 'testnet' | 'localnet';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AnchorProvider, BN, Program, web3 } from '@coral-xyz/anchor';
|
|
2
|
-
import { PublicKey, Transaction } from '@solana/web3.js';
|
|
3
|
-
import { ISolanaConnectionOptions, ISolanaVaultState } from './types';
|
|
1
|
+
import { AnchorProvider, BN, Program, type web3 } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey, type Transaction } from '@solana/web3.js';
|
|
3
|
+
import type { ISolanaConnectionOptions, ISolanaVaultState } from './types';
|
|
4
4
|
declare function getExplorerLink({ signature, type, network, }: {
|
|
5
5
|
signature: string;
|
|
6
6
|
type: 'tx' | 'address' | 'token';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { web3 } from '@coral-xyz/anchor';
|
|
2
|
-
import { Connection, PublicKey, Transaction } from '@solana/web3.js';
|
|
3
|
-
import { ISolanaConnectionOptions } from './types';
|
|
4
|
-
import { SendTransactionOptions } from '@solana/wallet-adapter-base';
|
|
1
|
+
import { type web3 } from '@coral-xyz/anchor';
|
|
2
|
+
import { type Connection, PublicKey, Transaction } from '@solana/web3.js';
|
|
3
|
+
import type { ISolanaConnectionOptions } from './types';
|
|
4
|
+
import type { SendTransactionOptions } from '@solana/wallet-adapter-base';
|
|
5
5
|
/**
|
|
6
6
|
* Deposit funds into a Solana August vault and mint share tokens.
|
|
7
7
|
*
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Builds unsigned Soroban transactions for vault deposit/redeem operations.
|
|
5
5
|
* Returns assembled XDR (base64) for wallet signing (e.g. Freighter).
|
|
6
6
|
*/
|
|
7
|
-
import { IStellarDepositParams, IStellarRedeemParams } from './types';
|
|
7
|
+
import type { IStellarDepositParams, IStellarRedeemParams } from './types';
|
|
8
8
|
/**
|
|
9
9
|
* Deposit assets into a Stellar vault (self-deposit).
|
|
10
10
|
*
|
|
@@ -53,8 +53,30 @@ declare class StellarAdapter {
|
|
|
53
53
|
*/
|
|
54
54
|
vaultRedeem(params: Omit<IStellarRedeemParams, 'network'>): Promise<string>;
|
|
55
55
|
/**
|
|
56
|
-
* Submit a signed Soroban transaction and poll until
|
|
57
|
-
*
|
|
56
|
+
* Submit a signed Soroban transaction and poll until the network confirms it.
|
|
57
|
+
*
|
|
58
|
+
* Submits on the network this adapter was constructed with, so `signedXdr`
|
|
59
|
+
* must be signed for that same network.
|
|
60
|
+
*
|
|
61
|
+
* @param signedXdr - Base64-encoded XDR of the signed transaction.
|
|
62
|
+
* @returns The transaction hash once the network confirms it as successful.
|
|
63
|
+
* @throws {@link AugustTimeoutError} when the transaction is not confirmed
|
|
64
|
+
* within the poll budget (`MAX_POLL_ATTEMPTS`).
|
|
65
|
+
* @throws {@link AugustSDKError} when the RPC rejects the submission or the
|
|
66
|
+
* transaction confirms as failed. Its `context` carries `{ network, status }`
|
|
67
|
+
* plus, when the result XDR decodes, a `resultCode` string holding the
|
|
68
|
+
* transaction-level reason (e.g. `"txBadSeq"`, `"txTooLate"`); `resultCode`
|
|
69
|
+
* is `undefined` when the code cannot be decoded.
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* try {
|
|
73
|
+
* const hash = await adapter.submitTransaction(signedXdr);
|
|
74
|
+
* } catch (err) {
|
|
75
|
+
* if (err instanceof AugustSDKError && err.context?.resultCode === 'txBadSeq') {
|
|
76
|
+
* // stale sequence number — rebuild the transaction and resubmit
|
|
77
|
+
* }
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
58
80
|
*/
|
|
59
81
|
submitTransaction(signedXdr: string): Promise<string>;
|
|
60
82
|
/**
|
|
@@ -69,6 +69,7 @@ exports.Stellar = {
|
|
|
69
69
|
* ```
|
|
70
70
|
*/
|
|
71
71
|
class StellarAdapter {
|
|
72
|
+
_network;
|
|
72
73
|
constructor(network = 'mainnet') {
|
|
73
74
|
this._network = network;
|
|
74
75
|
}
|
|
@@ -102,8 +103,30 @@ class StellarAdapter {
|
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
105
|
/**
|
|
105
|
-
* Submit a signed Soroban transaction and poll until
|
|
106
|
-
*
|
|
106
|
+
* Submit a signed Soroban transaction and poll until the network confirms it.
|
|
107
|
+
*
|
|
108
|
+
* Submits on the network this adapter was constructed with, so `signedXdr`
|
|
109
|
+
* must be signed for that same network.
|
|
110
|
+
*
|
|
111
|
+
* @param signedXdr - Base64-encoded XDR of the signed transaction.
|
|
112
|
+
* @returns The transaction hash once the network confirms it as successful.
|
|
113
|
+
* @throws {@link AugustTimeoutError} when the transaction is not confirmed
|
|
114
|
+
* within the poll budget (`MAX_POLL_ATTEMPTS`).
|
|
115
|
+
* @throws {@link AugustSDKError} when the RPC rejects the submission or the
|
|
116
|
+
* transaction confirms as failed. Its `context` carries `{ network, status }`
|
|
117
|
+
* plus, when the result XDR decodes, a `resultCode` string holding the
|
|
118
|
+
* transaction-level reason (e.g. `"txBadSeq"`, `"txTooLate"`); `resultCode`
|
|
119
|
+
* is `undefined` when the code cannot be decoded.
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* try {
|
|
123
|
+
* const hash = await adapter.submitTransaction(signedXdr);
|
|
124
|
+
* } catch (err) {
|
|
125
|
+
* if (err instanceof AugustSDKError && err.context?.resultCode === 'txBadSeq') {
|
|
126
|
+
* // stale sequence number — rebuild the transaction and resubmit
|
|
127
|
+
* }
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
107
130
|
*/
|
|
108
131
|
async submitTransaction(signedXdr) {
|
|
109
132
|
return StellarSubmit.submitStellarTransaction(signedXdr, this._network);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Common transaction building and read-only query helpers used by
|
|
5
5
|
* actions, submit, and getters modules.
|
|
6
6
|
*/
|
|
7
|
-
import { xdr, rpc } from '@stellar/stellar-sdk';
|
|
7
|
+
import { type xdr, rpc } from '@stellar/stellar-sdk';
|
|
8
8
|
import type { IStellarNetwork } from './types';
|
|
9
9
|
/** Resolved network configuration for Soroban RPC calls. */
|
|
10
10
|
export interface ISorobanNetworkConfig {
|
|
@@ -147,7 +147,7 @@ async function buildSorobanTx(config, sourceAddress, contractId, method, args) {
|
|
|
147
147
|
const msg = err instanceof Error ? err.message : String(err);
|
|
148
148
|
const isAccountNotFound = err instanceof stellar_sdk_1.NotFoundError || /Account not found/.test(msg);
|
|
149
149
|
if (isAccountNotFound) {
|
|
150
|
-
throw new core_1.AugustValidationError('
|
|
150
|
+
throw new core_1.AugustValidationError('ACCOUNT_NOT_FUNDED', `Stellar account ${sourceAddress} is not funded. Send at least 1 XLM to this address to activate it before depositing or redeeming.`, { cause: err, context: { sourceAddress, method, contractId } });
|
|
151
151
|
}
|
|
152
152
|
throw err;
|
|
153
153
|
}
|
|
@@ -7,8 +7,25 @@ import type { IStellarNetwork } from './types';
|
|
|
7
7
|
/**
|
|
8
8
|
* Submit a signed Soroban transaction and poll until confirmed.
|
|
9
9
|
*
|
|
10
|
-
* @param signedXdr Base64-encoded XDR of the signed transaction
|
|
11
|
-
* @param network Stellar network name
|
|
12
|
-
* @returns
|
|
10
|
+
* @param signedXdr - Base64-encoded XDR of the signed transaction
|
|
11
|
+
* @param network - Stellar network name
|
|
12
|
+
* @returns The transaction hash once the network confirms it as successful
|
|
13
|
+
* @throws {@link AugustTimeoutError} when the transaction is not confirmed
|
|
14
|
+
* within the poll budget (`MAX_POLL_ATTEMPTS`).
|
|
15
|
+
* @throws {@link AugustSDKError} when the RPC rejects the submission or the
|
|
16
|
+
* transaction confirms as failed. Its `context` carries `{ network, status }`
|
|
17
|
+
* plus, when the result XDR decodes, a `resultCode` string holding the
|
|
18
|
+
* transaction-level reason (e.g. `"txBadSeq"`, `"txTooLate"`); `resultCode`
|
|
19
|
+
* is `undefined` when the code cannot be decoded.
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* try {
|
|
23
|
+
* const hash = await submitStellarTransaction(signedXdr, 'mainnet');
|
|
24
|
+
* } catch (err) {
|
|
25
|
+
* if (err instanceof AugustSDKError && err.context?.resultCode === 'txBadSeq') {
|
|
26
|
+
* // stale sequence number — rebuild the transaction and resubmit
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
13
30
|
*/
|
|
14
31
|
export declare function submitStellarTransaction(signedXdr: string, network: IStellarNetwork): Promise<string>;
|