@augustdigital/sdk 9.10.1 → 9.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/lib/adapters/evm/index.d.ts +11 -3
- package/lib/adapters/evm/index.js +11 -3
- package/lib/adapters/solana/constants.d.ts +12 -4
- package/lib/adapters/solana/constants.js +8 -3
- package/lib/adapters/solana/getters.d.ts +5 -0
- package/lib/adapters/solana/getters.js +35 -1
- package/lib/adapters/solana/idl/vault-idl.d.ts +334 -7
- package/lib/adapters/solana/idl/vault-idl.js +600 -59
- package/lib/adapters/solana/idl/withdrawal-queue-idl.d.ts +790 -0
- package/lib/adapters/solana/idl/withdrawal-queue-idl.js +1868 -0
- package/lib/adapters/solana/index.d.ts +108 -10
- package/lib/adapters/solana/index.js +137 -12
- package/lib/adapters/solana/pricing.d.ts +11 -0
- package/lib/adapters/solana/pricing.js +24 -8
- package/lib/adapters/solana/queue.actions.d.ts +98 -0
- package/lib/adapters/solana/queue.actions.js +488 -0
- package/lib/adapters/solana/token-reads.d.ts +108 -0
- package/lib/adapters/solana/token-reads.js +145 -0
- package/lib/adapters/solana/types.d.ts +200 -1
- package/lib/adapters/solana/utils.d.ts +16 -0
- package/lib/adapters/solana/utils.js +41 -4
- package/lib/adapters/solana/vault.actions.d.ts +17 -0
- package/lib/adapters/solana/vault.actions.js +14 -125
- package/lib/adapters/solana/withdrawal-queue.d.ts +125 -0
- package/lib/adapters/solana/withdrawal-queue.js +301 -0
- package/lib/core/analytics/method-taxonomy.js +2 -0
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/helpers/swap-router.d.ts +17 -0
- package/lib/core/helpers/swap-router.js +44 -0
- package/lib/main.d.ts +16 -0
- package/lib/main.js +16 -0
- package/lib/modules/vaults/getters.d.ts +2 -2
- package/lib/modules/vaults/getters.js +103 -3
- package/lib/modules/vaults/main.d.ts +12 -0
- package/lib/modules/vaults/main.js +17 -1
- package/lib/modules/vaults/types.d.ts +14 -1
- package/lib/modules/vaults/write.actions.d.ts +27 -17
- package/lib/modules/vaults/write.actions.js +45 -16
- package/lib/sdk.d.ts +2420 -1734
- package/lib/types/vaults.d.ts +47 -1
- package/lib/types/vaults.js +5 -0
- package/lib/types/webserver.d.ts +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,19 +109,21 @@ const { registered, originFeeBps, collector } = await sdk.getOriginInfo({
|
|
|
109
109
|
- **Where it applies.** `vaultDeposit` sends a deposit through `SwapRouter.deposit` with the code when
|
|
110
110
|
`sdk.evm.getDepositRoute()` returns `via: 'router'`: the vault is registered on the router, the vault accepts
|
|
111
111
|
the asset as-is (its reference asset, or a Tokenized Vault V2 whitelisted asset — never swapped), the router
|
|
112
|
-
whitelists the asset, the deposit is not a permit, native-token or adapter deposit,
|
|
113
|
-
registered. `swapRouterDeposit`, `swapAndDeposit`, `depositViaSwapRouter` and `depositNativeViaSwapRouter`
|
|
112
|
+
whitelists the asset, the router is not paused, the deposit is not a permit, native-token or adapter deposit,
|
|
113
|
+
and the code is registered. `swapRouterDeposit`, `swapAndDeposit`, `depositViaSwapRouter` and `depositNativeViaSwapRouter`
|
|
114
114
|
send it too.
|
|
115
115
|
- **Precedence.** An `originCode` passed to a router method wins, then the instance code, then the all-zero
|
|
116
116
|
sentinel (no origin fee). Pass the zero sentinel to opt one call out.
|
|
117
117
|
- **Fallback.** When the code cannot be applied — it is not registered, the chain is not mainnet, the router
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
is paused (`router-paused`, checked with a 15-second cache) or does not whitelist the asset, the vault does
|
|
119
|
+
not accept it or is not registered on the router, or it is a permit, native-token or adapter deposit —
|
|
120
|
+
`vaultDeposit` takes the vault's native path and logs
|
|
120
121
|
`vaultDeposit:attribution-skipped` with the reason (Sentry tag `sdk.attribution.origin=skipped`). The router
|
|
121
122
|
methods send the zero sentinel for an unregistered instance code and log `<method>:attribution-skipped`.
|
|
122
123
|
With `strictOrigin: true` an unregistered instance code throws `AugustValidationError` before any approval
|
|
123
|
-
instead. An `originCode` passed to a router method that is
|
|
124
|
-
`AugustValidationError` before any approval.
|
|
124
|
+
instead; a paused router falls back to native even then. An `originCode` passed to a router method that is
|
|
125
|
+
not registered always throws `AugustValidationError` before any approval. While the router is paused, the
|
|
126
|
+
router methods throw `AugustSDKError` (`context.reason: 'router-paused'`) before any approval.
|
|
125
127
|
- **Approve `route.spender`, not the vault.** A routed deposit is pulled by the SwapRouter. `vaultDeposit` and
|
|
126
128
|
`approve` handle this; if you send approvals yourself, read the spender first:
|
|
127
129
|
|
|
@@ -106,9 +106,10 @@ declare class EVMAdapter {
|
|
|
106
106
|
* (`route.spender`, not necessarily the vault). See {@link getDepositRoute}.
|
|
107
107
|
*
|
|
108
108
|
* @param options - {@link IGetDepositRouteOptions}.
|
|
109
|
-
* @returns `{ via, spender, reason? }` — `reason` explains a native route
|
|
109
|
+
* @returns `{ via, spender, reason? }` — `reason` explains a native route
|
|
110
|
+
* (`router-paused` while the SwapRouter is paused).
|
|
110
111
|
* @throws AugustValidationError on an invalid target, or an unregistered
|
|
111
|
-
* code under `attribution.strictOrigin
|
|
112
|
+
* code under `attribution.strictOrigin` while the router is not paused.
|
|
112
113
|
* @throws AugustSDKError when a backend, vault or router read fails.
|
|
113
114
|
* @example
|
|
114
115
|
* ```ts
|
|
@@ -174,7 +175,8 @@ declare class EVMAdapter {
|
|
|
174
175
|
* @param options - {@link ISwapAndDepositOptions}.
|
|
175
176
|
* @returns The transaction hash of the `swapAndDeposit` call.
|
|
176
177
|
* @throws AugustValidationError on invalid inputs (bad chain, empty swaps).
|
|
177
|
-
* @throws AugustSDKError
|
|
178
|
+
* @throws AugustSDKError while the SwapRouter is paused (checked before any
|
|
179
|
+
* approval), or on RPC / contract revert.
|
|
178
180
|
*
|
|
179
181
|
* @example
|
|
180
182
|
* ```ts
|
|
@@ -198,6 +200,8 @@ declare class EVMAdapter {
|
|
|
198
200
|
*
|
|
199
201
|
* @param options - {@link ISwapRouterDirectDepositOptions}.
|
|
200
202
|
* @returns The transaction hash of the `deposit` call.
|
|
203
|
+
* @throws AugustSDKError while the SwapRouter is paused (checked before any
|
|
204
|
+
* approval), or on RPC / contract revert.
|
|
201
205
|
*/
|
|
202
206
|
depositViaSwapRouter(options: ISwapRouterDirectDepositOptions): Promise<string>;
|
|
203
207
|
/**
|
|
@@ -207,6 +211,8 @@ declare class EVMAdapter {
|
|
|
207
211
|
*
|
|
208
212
|
* @param options - {@link ISwapRouterNativeDepositOptions}.
|
|
209
213
|
* @returns The transaction hash of the `depositNativeToken` call.
|
|
214
|
+
* @throws AugustSDKError while the SwapRouter is paused (checked before any
|
|
215
|
+
* approval), or on RPC / contract revert.
|
|
210
216
|
*/
|
|
211
217
|
depositNativeViaSwapRouter(options: ISwapRouterNativeDepositOptions): Promise<string>;
|
|
212
218
|
/**
|
|
@@ -224,6 +230,8 @@ declare class EVMAdapter {
|
|
|
224
230
|
* @returns The transaction hash of the router deposit call.
|
|
225
231
|
* @throws AugustValidationError on unsupported chain, invalid address, zero
|
|
226
232
|
* amount, a native deposit into a non-wrapped-native vault, or quote drift.
|
|
233
|
+
* @throws AugustSDKError while the SwapRouter is paused (checked before any
|
|
234
|
+
* approval), or on RPC / contract revert.
|
|
227
235
|
* @example
|
|
228
236
|
* ```ts
|
|
229
237
|
* const hash = await augustSdk.evm.swapRouterDeposit({
|
|
@@ -154,9 +154,10 @@ class EVMAdapter {
|
|
|
154
154
|
* (`route.spender`, not necessarily the vault). See {@link getDepositRoute}.
|
|
155
155
|
*
|
|
156
156
|
* @param options - {@link IGetDepositRouteOptions}.
|
|
157
|
-
* @returns `{ via, spender, reason? }` — `reason` explains a native route
|
|
157
|
+
* @returns `{ via, spender, reason? }` — `reason` explains a native route
|
|
158
|
+
* (`router-paused` while the SwapRouter is paused).
|
|
158
159
|
* @throws AugustValidationError on an invalid target, or an unregistered
|
|
159
|
-
* code under `attribution.strictOrigin
|
|
160
|
+
* code under `attribution.strictOrigin` while the router is not paused.
|
|
160
161
|
* @throws AugustSDKError when a backend, vault or router read fails.
|
|
161
162
|
* @example
|
|
162
163
|
* ```ts
|
|
@@ -231,7 +232,8 @@ class EVMAdapter {
|
|
|
231
232
|
* @param options - {@link ISwapAndDepositOptions}.
|
|
232
233
|
* @returns The transaction hash of the `swapAndDeposit` call.
|
|
233
234
|
* @throws AugustValidationError on invalid inputs (bad chain, empty swaps).
|
|
234
|
-
* @throws AugustSDKError
|
|
235
|
+
* @throws AugustSDKError while the SwapRouter is paused (checked before any
|
|
236
|
+
* approval), or on RPC / contract revert.
|
|
235
237
|
*
|
|
236
238
|
* @example
|
|
237
239
|
* ```ts
|
|
@@ -258,6 +260,8 @@ class EVMAdapter {
|
|
|
258
260
|
*
|
|
259
261
|
* @param options - {@link ISwapRouterDirectDepositOptions}.
|
|
260
262
|
* @returns The transaction hash of the `deposit` call.
|
|
263
|
+
* @throws AugustSDKError while the SwapRouter is paused (checked before any
|
|
264
|
+
* approval), or on RPC / contract revert.
|
|
261
265
|
*/
|
|
262
266
|
async depositViaSwapRouter(options) {
|
|
263
267
|
const signer = await this._getSigner();
|
|
@@ -270,6 +274,8 @@ class EVMAdapter {
|
|
|
270
274
|
*
|
|
271
275
|
* @param options - {@link ISwapRouterNativeDepositOptions}.
|
|
272
276
|
* @returns The transaction hash of the `depositNativeToken` call.
|
|
277
|
+
* @throws AugustSDKError while the SwapRouter is paused (checked before any
|
|
278
|
+
* approval), or on RPC / contract revert.
|
|
273
279
|
*/
|
|
274
280
|
async depositNativeViaSwapRouter(options) {
|
|
275
281
|
const signer = await this._getSigner();
|
|
@@ -290,6 +296,8 @@ class EVMAdapter {
|
|
|
290
296
|
* @returns The transaction hash of the router deposit call.
|
|
291
297
|
* @throws AugustValidationError on unsupported chain, invalid address, zero
|
|
292
298
|
* amount, a native deposit into a non-wrapped-native vault, or quote drift.
|
|
299
|
+
* @throws AugustSDKError while the SwapRouter is paused (checked before any
|
|
300
|
+
* approval), or on RPC / contract revert.
|
|
293
301
|
* @example
|
|
294
302
|
* ```ts
|
|
295
303
|
* const hash = await augustSdk.evm.swapRouterDeposit({
|
|
@@ -2,6 +2,14 @@ import type { ISolanaNetwork } from '../../types';
|
|
|
2
2
|
import { vaultIdl } from './idl/vault-idl';
|
|
3
3
|
declare const fallbackDecimals = 8;
|
|
4
4
|
declare const fallbackNetwork: ISolanaNetwork;
|
|
5
|
+
/**
|
|
6
|
+
* Program ids deployed on one Solana network. `withdrawalQueue` is absent where
|
|
7
|
+
* the queue program is not deployed yet (currently mainnet-beta).
|
|
8
|
+
*/
|
|
9
|
+
type ISolanaProgramIds = {
|
|
10
|
+
vault: string;
|
|
11
|
+
withdrawalQueue?: string;
|
|
12
|
+
};
|
|
5
13
|
declare const fallbackRpcEndpoints: {
|
|
6
14
|
readonly devnet: "https://api.devnet.solana.com";
|
|
7
15
|
readonly mainnet: "https://api.mainnet-beta.solana.com";
|
|
@@ -11,12 +19,14 @@ declare const fallbackRpcEndpoints: {
|
|
|
11
19
|
declare const programIds: {
|
|
12
20
|
devnet: {
|
|
13
21
|
vault: string;
|
|
22
|
+
withdrawalQueue: string;
|
|
14
23
|
};
|
|
15
24
|
"mainnet-beta": {
|
|
16
25
|
vault: string;
|
|
17
26
|
};
|
|
18
27
|
localnet: {
|
|
19
28
|
vault: string;
|
|
29
|
+
withdrawalQueue: string;
|
|
20
30
|
};
|
|
21
31
|
};
|
|
22
32
|
/** Solana networks the canonical august_vault program is actually deployed on. */
|
|
@@ -26,8 +36,6 @@ type ISolanaDeployedNetwork = keyof typeof programIds;
|
|
|
26
36
|
* deployment there (currently `testnet`). Callers must handle `undefined` —
|
|
27
37
|
* silently substituting a default would hand back a dead address.
|
|
28
38
|
*/
|
|
29
|
-
declare function getDeployedProgramIds(network: ISolanaNetwork):
|
|
30
|
-
vault: string;
|
|
31
|
-
} | undefined;
|
|
39
|
+
declare function getDeployedProgramIds(network: ISolanaNetwork): ISolanaProgramIds | undefined;
|
|
32
40
|
export { fallbackDecimals, fallbackNetwork, fallbackRpcEndpoints, getDeployedProgramIds, programIds, vaultIdl, };
|
|
33
|
-
export type { ISolanaDeployedNetwork };
|
|
41
|
+
export type { ISolanaDeployedNetwork, ISolanaProgramIds };
|
|
@@ -8,9 +8,6 @@ const fallbackDecimals = 8;
|
|
|
8
8
|
exports.fallbackDecimals = fallbackDecimals;
|
|
9
9
|
const fallbackNetwork = 'mainnet-beta';
|
|
10
10
|
exports.fallbackNetwork = fallbackNetwork;
|
|
11
|
-
// ============================================================================
|
|
12
|
-
// SOLANA CONFIGURATION
|
|
13
|
-
// ============================================================================
|
|
14
11
|
const fallbackRpcEndpoints = {
|
|
15
12
|
devnet: 'https://api.devnet.solana.com',
|
|
16
13
|
mainnet: 'https://api.mainnet-beta.solana.com',
|
|
@@ -29,15 +26,23 @@ exports.fallbackRpcEndpoints = fallbackRpcEndpoints;
|
|
|
29
26
|
// transaction. Unmapped networks throw from `getProgram`/`getProgramId` instead.
|
|
30
27
|
// `satisfies` keeps the literal ids in the generated docs while checking keys
|
|
31
28
|
// against ISolanaNetwork, so `testnet` is absent from the type, not optional.
|
|
29
|
+
//
|
|
30
|
+
// `withdrawalQueue` is the august_withdrawal_queue program. Its id is fixed (the
|
|
31
|
+
// vault binary hardcodes it as `WITHDRAWAL_QUEUE_PROGRAM_ID`), but it is mapped
|
|
32
|
+
// only where deployed: devnet and localnet. Mainnet-beta still runs the pre-queue
|
|
33
|
+
// vault build, which the bundled vault IDL stays compatible with; add the entry
|
|
34
|
+
// there once the mainnet upgrade deploys the queue.
|
|
32
35
|
const programIds = {
|
|
33
36
|
devnet: {
|
|
34
37
|
vault: 'up12bytoZBmwofqsySf2uqKQ7zpfeKiAWwfvqzJjtRt',
|
|
38
|
+
withdrawalQueue: 'upQhC7mgYwmHLVaatRWoGAu394piLT9th9FiQZHnPrW',
|
|
35
39
|
},
|
|
36
40
|
['mainnet-beta']: {
|
|
37
41
|
vault: 'up12bytoZBmwofqsySf2uqKQ7zpfeKiAWwfvqzJjtRt',
|
|
38
42
|
},
|
|
39
43
|
localnet: {
|
|
40
44
|
vault: 'up12bytoZBmwofqsySf2uqKQ7zpfeKiAWwfvqzJjtRt',
|
|
45
|
+
withdrawalQueue: 'upQhC7mgYwmHLVaatRWoGAu394piLT9th9FiQZHnPrW',
|
|
41
46
|
},
|
|
42
47
|
};
|
|
43
48
|
exports.programIds = programIds;
|
|
@@ -4,6 +4,11 @@ import type { IVaultBaseOptions } from '../../modules/vaults/types';
|
|
|
4
4
|
* Fetch Solana vault data from on-chain program state.
|
|
5
5
|
* Falls back to backend-only data when Solana RPC is unavailable,
|
|
6
6
|
* ensuring vaults always appear in the list even without on-chain access.
|
|
7
|
+
*
|
|
8
|
+
* When the vault has a withdrawal queue, `withdrawalQueue` carries its live
|
|
9
|
+
* summary, at the cost of one extra `getMultipleAccountsInfo` (the queue and a
|
|
10
|
+
* fresh read of the vault state, for `enabled`). A failed queue read is
|
|
11
|
+
* logged and leaves the field out rather than failing the vault.
|
|
7
12
|
* @param tokenizedVault Vault metadata from backend
|
|
8
13
|
* @param options RPC configuration with Solana service
|
|
9
14
|
* @returns Formatted vault object with Solana-specific fields
|
|
@@ -39,10 +39,16 @@ const utils_1 = require("./utils");
|
|
|
39
39
|
const SolanaConstants = __importStar(require("./constants"));
|
|
40
40
|
const core_1 = require("../../core");
|
|
41
41
|
const utils_2 = require("../../modules/vaults/utils");
|
|
42
|
+
const withdrawal_queue_1 = require("./withdrawal-queue");
|
|
42
43
|
/**
|
|
43
44
|
* Fetch Solana vault data from on-chain program state.
|
|
44
45
|
* Falls back to backend-only data when Solana RPC is unavailable,
|
|
45
46
|
* ensuring vaults always appear in the list even without on-chain access.
|
|
47
|
+
*
|
|
48
|
+
* When the vault has a withdrawal queue, `withdrawalQueue` carries its live
|
|
49
|
+
* summary, at the cost of one extra `getMultipleAccountsInfo` (the queue and a
|
|
50
|
+
* fresh read of the vault state, for `enabled`). A failed queue read is
|
|
51
|
+
* logged and leaves the field out rather than failing the vault.
|
|
46
52
|
* @param tokenizedVault Vault metadata from backend
|
|
47
53
|
* @param options RPC configuration with Solana service
|
|
48
54
|
* @returns Formatted vault object with Solana-specific fields
|
|
@@ -101,6 +107,7 @@ const getSolanaVault = async (tokenizedVault, options) => {
|
|
|
101
107
|
// Prefer vaultState.shareMint (correct for multi-vault programs like jitoSOL);
|
|
102
108
|
// fall back to deriveShareMintPda(programId) for legacy single-vault programs.
|
|
103
109
|
let totalSupply = (0, core_1.toNormalizedBn)(0, decimals);
|
|
110
|
+
let shareDecimals = decimals;
|
|
104
111
|
if (onChainAvailable) {
|
|
105
112
|
try {
|
|
106
113
|
const shareMintFromState = vaultState?.vaultState?.shareMint;
|
|
@@ -112,6 +119,7 @@ const getSolanaVault = async (tokenizedVault, options) => {
|
|
|
112
119
|
const parsedData = shareMintAccountInfo.value.data;
|
|
113
120
|
const { supply, decimals: mintDecimals } = parsedData.parsed.info;
|
|
114
121
|
totalSupply = (0, core_1.toNormalizedBn)(BigInt(supply), mintDecimals);
|
|
122
|
+
shareDecimals = mintDecimals;
|
|
115
123
|
}
|
|
116
124
|
}
|
|
117
125
|
catch (error) {
|
|
@@ -152,8 +160,31 @@ const getSolanaVault = async (tokenizedVault, options) => {
|
|
|
152
160
|
vault: tokenizedVault.address,
|
|
153
161
|
});
|
|
154
162
|
}
|
|
163
|
+
let withdrawalQueue;
|
|
164
|
+
const solanaService = options.solanaService;
|
|
165
|
+
if (onChainAvailable && vaultState?.vaultState && solanaService) {
|
|
166
|
+
try {
|
|
167
|
+
const queueProgramId = (0, withdrawal_queue_1.resolveQueueProgramId)(solanaService);
|
|
168
|
+
withdrawalQueue = queueProgramId
|
|
169
|
+
? await (0, withdrawal_queue_1.getSolanaWithdrawalQueueSummary)({
|
|
170
|
+
connection: solanaService.connection,
|
|
171
|
+
queueProgramId,
|
|
172
|
+
vaultState: solanaMetadata?.vault_state_pda
|
|
173
|
+
? new web3_js_1.PublicKey(solanaMetadata.vault_state_pda)
|
|
174
|
+
: utils_1.SolanaUtils.deriveVaultStatePda(programId),
|
|
175
|
+
shareDecimals,
|
|
176
|
+
})
|
|
177
|
+
: undefined;
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
core_1.Logger.log.warn('getSolanaVault', 'Withdrawal queue read failed', {
|
|
181
|
+
vault: tokenizedVault.address,
|
|
182
|
+
error,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
155
186
|
// Build unified vault object combining on-chain and backend data
|
|
156
|
-
|
|
187
|
+
const vault = (0, utils_2.buildBackendVault)(tokenizedVault, {
|
|
157
188
|
chainId: core_1.SPECIAL_CHAINS.solana.chainId,
|
|
158
189
|
version: 'sol-0',
|
|
159
190
|
name: tokenizedVault.vault_name || 'Solana Program',
|
|
@@ -167,6 +198,9 @@ const getSolanaVault = async (tokenizedVault, options) => {
|
|
|
167
198
|
},
|
|
168
199
|
programId,
|
|
169
200
|
});
|
|
201
|
+
if (withdrawalQueue)
|
|
202
|
+
vault.withdrawalQueue = withdrawalQueue;
|
|
203
|
+
return vault;
|
|
170
204
|
};
|
|
171
205
|
exports.getSolanaVault = getSolanaVault;
|
|
172
206
|
//# sourceMappingURL=getters.js.map
|