@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
|
@@ -40,7 +40,7 @@ async function fetchInstantRedemptionFee(signer, options) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
catch (e) {
|
|
43
|
-
core_1.
|
|
43
|
+
(0, core_1.logChainError)('failed to fetch instant redeem fee', e, (0, core_1.isExpectedRevertError)(e));
|
|
44
44
|
throw new Error(`Failed to fetch instant redeem fee for ${target}: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -83,7 +83,7 @@ async function vaultAllowance(signer, options) {
|
|
|
83
83
|
return normalized;
|
|
84
84
|
}
|
|
85
85
|
catch (e) {
|
|
86
|
-
core_1.
|
|
86
|
+
(0, core_1.logChainError)('allowance', e, (0, core_1.isExpectedRevertError)(e));
|
|
87
87
|
throw new Error(`Failed to fetch allowance: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -109,7 +109,7 @@ async function sendersWhitelistAddress(signer, options) {
|
|
|
109
109
|
return whitelistAddress;
|
|
110
110
|
}
|
|
111
111
|
catch (e) {
|
|
112
|
-
core_1.
|
|
112
|
+
(0, core_1.logChainError)('sendersWhitelistAddress', e, (0, core_1.isExpectedRevertError)(e));
|
|
113
113
|
throw new Error(`Failed to fetch senders whitelist address: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -138,7 +138,7 @@ async function isWhitelisted(signer, options) {
|
|
|
138
138
|
return result;
|
|
139
139
|
}
|
|
140
140
|
catch (e) {
|
|
141
|
-
core_1.
|
|
141
|
+
(0, core_1.logChainError)('isWhitelisted', e, (0, core_1.isExpectedRevertError)(e));
|
|
142
142
|
throw new Error(`Failed to check whitelist status: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -183,7 +183,7 @@ async function getDeposited(signer, options) {
|
|
|
183
183
|
return normalized;
|
|
184
184
|
}
|
|
185
185
|
catch (e) {
|
|
186
|
-
core_1.
|
|
186
|
+
(0, core_1.logChainError)('getDeposited', e, (0, core_1.isExpectedRevertError)(e));
|
|
187
187
|
throw new Error(`Failed to fetch deposited amount: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
@@ -232,7 +232,7 @@ async function getRemainingAllocations(signer, options) {
|
|
|
232
232
|
return normalized;
|
|
233
233
|
}
|
|
234
234
|
catch (e) {
|
|
235
|
-
core_1.
|
|
235
|
+
(0, core_1.logChainError)('getRemainingAllocations', e, (0, core_1.isExpectedRevertError)(e));
|
|
236
236
|
throw new Error(`Failed to fetch remaining allocations: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
@@ -263,7 +263,11 @@ async function previewRwaRedemption(signer, options) {
|
|
|
263
263
|
return normalized;
|
|
264
264
|
}
|
|
265
265
|
catch (e) {
|
|
266
|
-
core_1.
|
|
266
|
+
(0, core_1.logChainError)('previewRwaRedemption', e, (0, core_1.isExpectedRevertError)(e), {
|
|
267
|
+
target,
|
|
268
|
+
asset,
|
|
269
|
+
amount,
|
|
270
|
+
});
|
|
267
271
|
throw new Error(`Preview RWA redemption failed: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
268
272
|
}
|
|
269
273
|
}
|
|
@@ -354,7 +358,10 @@ async function previewDeposit(signer, options) {
|
|
|
354
358
|
if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
|
|
355
359
|
throw e;
|
|
356
360
|
}
|
|
357
|
-
core_1.
|
|
361
|
+
(0, core_1.logChainError)('previewDeposit', e, (0, core_1.isExpectedRevertError)(e), {
|
|
362
|
+
vault,
|
|
363
|
+
amount: amount.toString(),
|
|
364
|
+
});
|
|
358
365
|
throw new core_1.AugustSDKError('UNKNOWN', `previewDeposit failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault, amount: amount.toString() } });
|
|
359
366
|
}
|
|
360
367
|
}
|
|
@@ -410,7 +417,7 @@ async function previewRedeem(signer, options) {
|
|
|
410
417
|
if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
|
|
411
418
|
throw e;
|
|
412
419
|
}
|
|
413
|
-
core_1.
|
|
420
|
+
(0, core_1.logChainError)('previewRedeem', e, (0, core_1.isExpectedRevertError)(e), {
|
|
414
421
|
vault,
|
|
415
422
|
shares: shares.toString(),
|
|
416
423
|
});
|
|
@@ -480,7 +487,11 @@ async function allowance(signer, options) {
|
|
|
480
487
|
if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
|
|
481
488
|
throw e;
|
|
482
489
|
}
|
|
483
|
-
core_1.
|
|
490
|
+
(0, core_1.logChainError)('allowance', e, (0, core_1.isExpectedRevertError)(e), {
|
|
491
|
+
vault,
|
|
492
|
+
owner,
|
|
493
|
+
asset,
|
|
494
|
+
});
|
|
484
495
|
throw new core_1.AugustSDKError('UNKNOWN', `allowance failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault, owner, asset } });
|
|
485
496
|
}
|
|
486
497
|
}
|
|
@@ -521,7 +532,7 @@ async function balanceOf(signer, options) {
|
|
|
521
532
|
if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
|
|
522
533
|
throw e;
|
|
523
534
|
}
|
|
524
|
-
core_1.
|
|
535
|
+
(0, core_1.logChainError)('balanceOf', e, (0, core_1.isExpectedRevertError)(e), { asset, owner });
|
|
525
536
|
throw new core_1.AugustSDKError('UNKNOWN', `balanceOf failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { asset, owner } });
|
|
526
537
|
}
|
|
527
538
|
}
|
|
@@ -575,7 +586,10 @@ async function maxDeposit(signer, options) {
|
|
|
575
586
|
if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
|
|
576
587
|
throw e;
|
|
577
588
|
}
|
|
578
|
-
core_1.
|
|
589
|
+
(0, core_1.logChainError)('maxDeposit', e, (0, core_1.isExpectedRevertError)(e), {
|
|
590
|
+
vault,
|
|
591
|
+
receiver,
|
|
592
|
+
});
|
|
579
593
|
throw new core_1.AugustSDKError('UNKNOWN', `maxDeposit failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault, receiver } });
|
|
580
594
|
}
|
|
581
595
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Decodes transaction calldata to extract which (year, month, day) cluster
|
|
5
5
|
* was processed when a WithdrawalProcessed event was emitted.
|
|
6
6
|
*/
|
|
7
|
-
import { ContractTransactionReceipt, Interface } from 'ethers';
|
|
7
|
+
import type { ContractTransactionReceipt, Interface } from 'ethers';
|
|
8
8
|
export interface ProcessingCallData {
|
|
9
9
|
functionName: 'processAllClaimsByDate' | 'claim' | 'unknown';
|
|
10
10
|
year: number;
|
|
@@ -16,9 +16,18 @@ export declare function walletClientToSigner(walletClient: WalletClient): Promis
|
|
|
16
16
|
*/
|
|
17
17
|
export declare const getRewardMultiplierByTimestamp: (foundPool: IVault, timestamp?: number) => number;
|
|
18
18
|
/**
|
|
19
|
-
* Get the rewards for the vault
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Get the rewards for the vault.
|
|
20
|
+
*
|
|
21
|
+
* Builds the display-facing rewards summary from the raw tokenized-vault
|
|
22
|
+
* rewards array. In addition to the legacy `additionalPoints` string list, it
|
|
23
|
+
* emits `additionalPointsDetailed`, which pairs each label with its
|
|
24
|
+
* backend-provided `img_url`. Consumers (e.g. the Upshift app) resolve a
|
|
25
|
+
* reward's logo from this `imgUrl` first, falling back to a bundled asset only
|
|
26
|
+
* when it is absent — so a newly-added reward with a backend logo (e.g.
|
|
27
|
+
* "Cores") renders its icon without any client-side keyword mapping.
|
|
28
|
+
*
|
|
29
|
+
* @param tokenizedVault - The tokenized vault.
|
|
30
|
+
* @returns The rewards summary, including `additionalPointsDetailed`.
|
|
22
31
|
*/
|
|
23
32
|
export declare function getVaultRewards(tokenizedVault: ITokenizedVault): {
|
|
24
33
|
points: string;
|
|
@@ -28,6 +37,13 @@ export declare function getVaultRewards(tokenizedVault: ITokenizedVault): {
|
|
|
28
37
|
value: number;
|
|
29
38
|
}[];
|
|
30
39
|
additionalPoints: string[];
|
|
40
|
+
additionalPointsDetailed: {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
text: string;
|
|
44
|
+
imgUrl: string;
|
|
45
|
+
multiplier: number;
|
|
46
|
+
}[];
|
|
31
47
|
};
|
|
32
48
|
/**
|
|
33
49
|
* Get the idle assets for the vault
|
|
@@ -72,9 +72,34 @@ const getRewardMultiplierByTimestamp = (foundPool, timestamp) => {
|
|
|
72
72
|
};
|
|
73
73
|
exports.getRewardMultiplierByTimestamp = getRewardMultiplierByTimestamp;
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
75
|
+
* Build the human-readable display label for a single reward.
|
|
76
|
+
*
|
|
77
|
+
* The format is `"{multiplier}x {text}"`, with the multiplier prefix omitted
|
|
78
|
+
* when it equals 1 (e.g. `"2x Cores"`, `" Cores"` when multiplier is 1 — the
|
|
79
|
+
* leading space is preserved to keep `additionalPoints` and the
|
|
80
|
+
* `additionalPointsDetailed` label in lockstep). This is a display string only;
|
|
81
|
+
* consumers that need a stable key should join on the reward's `id`
|
|
82
|
+
* (see {@link IVaultRewardDetail}), not on this label.
|
|
83
|
+
*
|
|
84
|
+
* @param reward - The raw tokenized-vault reward.
|
|
85
|
+
* @returns The display label string.
|
|
86
|
+
*/
|
|
87
|
+
function getRewardLabel(reward) {
|
|
88
|
+
return `${reward.multiplier !== 1 ? `${reward.multiplier}x` : ''} ${reward.text}`;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get the rewards for the vault.
|
|
92
|
+
*
|
|
93
|
+
* Builds the display-facing rewards summary from the raw tokenized-vault
|
|
94
|
+
* rewards array. In addition to the legacy `additionalPoints` string list, it
|
|
95
|
+
* emits `additionalPointsDetailed`, which pairs each label with its
|
|
96
|
+
* backend-provided `img_url`. Consumers (e.g. the Upshift app) resolve a
|
|
97
|
+
* reward's logo from this `imgUrl` first, falling back to a bundled asset only
|
|
98
|
+
* when it is absent — so a newly-added reward with a backend logo (e.g.
|
|
99
|
+
* "Cores") renders its icon without any client-side keyword mapping.
|
|
100
|
+
*
|
|
101
|
+
* @param tokenizedVault - The tokenized vault.
|
|
102
|
+
* @returns The rewards summary, including `additionalPointsDetailed`.
|
|
78
103
|
*/
|
|
79
104
|
function getVaultRewards(tokenizedVault) {
|
|
80
105
|
const upshiftPointRewards = tokenizedVault.rewards?.filter((r) => r.text === 'Upshift Points');
|
|
@@ -91,7 +116,14 @@ function getVaultRewards(tokenizedVault) {
|
|
|
91
116
|
: '',
|
|
92
117
|
multiplier: latestUpshiftPointMultiplier,
|
|
93
118
|
multipliers: upshiftPointsMultipliers,
|
|
94
|
-
additionalPoints: tokenizedVault.rewards.map(
|
|
119
|
+
additionalPoints: tokenizedVault.rewards.map(getRewardLabel),
|
|
120
|
+
additionalPointsDetailed: tokenizedVault.rewards.map((r) => ({
|
|
121
|
+
id: r.id,
|
|
122
|
+
label: getRewardLabel(r),
|
|
123
|
+
text: r.text,
|
|
124
|
+
imgUrl: r.img_url || null,
|
|
125
|
+
multiplier: r.multiplier,
|
|
126
|
+
})),
|
|
95
127
|
};
|
|
96
128
|
return rewards;
|
|
97
129
|
}
|
|
@@ -289,6 +321,7 @@ function buildBackendVault(tokenizedVault, overrides) {
|
|
|
289
321
|
multiplier: 0,
|
|
290
322
|
multipliers: [],
|
|
291
323
|
additionalPoints: [],
|
|
324
|
+
additionalPointsDetailed: [],
|
|
292
325
|
};
|
|
293
326
|
return {
|
|
294
327
|
operator: '0x',
|
|
@@ -313,7 +346,7 @@ function buildBackendVault(tokenizedVault, overrides) {
|
|
|
313
346
|
reserveTolerance: tokenizedVault.reserve_tolerance || 0,
|
|
314
347
|
// Vault decimals are derived from the receipt token decimals for non-EVM vaults
|
|
315
348
|
decimals: overrides.receipt.decimals,
|
|
316
|
-
maxSupply: (0, core_1.toNormalizedBn)(
|
|
349
|
+
maxSupply: (0, core_1.toNormalizedBn)(1_000_000_000),
|
|
317
350
|
depositCap: null,
|
|
318
351
|
apy,
|
|
319
352
|
rewards,
|
|
@@ -498,7 +531,7 @@ async function buildFormattedVault(provider, tokenizedVault, contractCalls) {
|
|
|
498
531
|
depositAssets = [...depositAssets, ...extraAssets];
|
|
499
532
|
totalSupply = contractCalls.totalSupply;
|
|
500
533
|
(maxSupply =
|
|
501
|
-
(0, core_1.toNormalizedBn)(
|
|
534
|
+
(0, core_1.toNormalizedBn)(1_000_000_000_000)), // @hardcoded: no maxSupply on here
|
|
502
535
|
(receipt = {
|
|
503
536
|
symbol: tokenizedVault.receipt_token_symbol,
|
|
504
537
|
address: contractCalls.lpTokenAddress,
|
|
@@ -90,7 +90,7 @@ function validateAmountPrecision(amount) {
|
|
|
90
90
|
}
|
|
91
91
|
// Tries tx.wait() first (preserves replacement detection & revert checks), then falls back to
|
|
92
92
|
// provider.waitForTransaction() for RPCs (e.g. Monad) that return malformed pending tx fields.
|
|
93
|
-
const SAFE_WAIT_TIMEOUT_MS =
|
|
93
|
+
const SAFE_WAIT_TIMEOUT_MS = 120_000;
|
|
94
94
|
/** @internal */
|
|
95
95
|
function isNonceParsing(error) {
|
|
96
96
|
const code = error?.code;
|
|
@@ -297,7 +297,12 @@ async function approveCore(signer, options) {
|
|
|
297
297
|
catch (e) {
|
|
298
298
|
if (e instanceof core_1.AugustSDKError)
|
|
299
299
|
throw e;
|
|
300
|
-
|
|
300
|
+
// A user declining the approval in their wallet is product behaviour, not
|
|
301
|
+
// an SDK fault — demote it to a breadcrumb so it doesn't bill as an issue.
|
|
302
|
+
(0, core_1.logChainError)('vaultApprove', e, (0, core_1.isUserRejectionError)(e), {
|
|
303
|
+
target,
|
|
304
|
+
amount,
|
|
305
|
+
});
|
|
301
306
|
throw new core_1.AugustSDKError('UNKNOWN', `Approval failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { target, amount } });
|
|
302
307
|
}
|
|
303
308
|
}
|
|
@@ -632,7 +637,12 @@ async function vaultDeposit(signer, options) {
|
|
|
632
637
|
}
|
|
633
638
|
if (e instanceof core_1.AugustSDKError)
|
|
634
639
|
throw e;
|
|
635
|
-
|
|
640
|
+
// User-cancelled deposits are normal; only genuine failures stay at error.
|
|
641
|
+
(0, core_1.logChainError)('deposit', e, (0, core_1.isUserRejectionError)(e), {
|
|
642
|
+
target,
|
|
643
|
+
amount,
|
|
644
|
+
depositAsset,
|
|
645
|
+
});
|
|
636
646
|
throw new core_1.AugustSDKError('UNKNOWN', `Deposit failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { target, amount, depositAsset } });
|
|
637
647
|
}
|
|
638
648
|
}
|
|
@@ -780,7 +790,11 @@ async function vaultRequestRedeem(signer, options) {
|
|
|
780
790
|
}
|
|
781
791
|
if (e instanceof core_1.AugustSDKError)
|
|
782
792
|
throw e;
|
|
783
|
-
|
|
793
|
+
// User-cancelled redeem requests are normal; only genuine failures stay at error.
|
|
794
|
+
(0, core_1.logChainError)('requestRedeem', e, (0, core_1.isUserRejectionError)(e), {
|
|
795
|
+
target,
|
|
796
|
+
amount,
|
|
797
|
+
});
|
|
784
798
|
throw new core_1.AugustSDKError('UNKNOWN', `Request redeem failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { target, amount } });
|
|
785
799
|
}
|
|
786
800
|
}
|
|
@@ -823,7 +837,14 @@ async function vaultRedeem(signer, options) {
|
|
|
823
837
|
}
|
|
824
838
|
if (e instanceof core_1.AugustSDKError)
|
|
825
839
|
throw e;
|
|
826
|
-
|
|
840
|
+
// User-cancelled redeems are normal; only genuine failures stay at error.
|
|
841
|
+
(0, core_1.logChainError)('redeem', e, (0, core_1.isUserRejectionError)(e), {
|
|
842
|
+
target,
|
|
843
|
+
year,
|
|
844
|
+
month,
|
|
845
|
+
day,
|
|
846
|
+
receiverIndex,
|
|
847
|
+
});
|
|
827
848
|
throw new core_1.AugustSDKError('UNKNOWN', `Redeem failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { target, year, month, day, receiverIndex } });
|
|
828
849
|
}
|
|
829
850
|
}
|
|
@@ -914,7 +935,12 @@ async function depositNative(signer, options) {
|
|
|
914
935
|
}
|
|
915
936
|
if (e instanceof core_1.AugustSDKError)
|
|
916
937
|
throw e;
|
|
917
|
-
|
|
938
|
+
// User-cancelled native deposits are normal; only genuine failures stay at error.
|
|
939
|
+
(0, core_1.logChainError)('depositNative', e, (0, core_1.isUserRejectionError)(e), {
|
|
940
|
+
wrapperAddress,
|
|
941
|
+
receiver,
|
|
942
|
+
amount,
|
|
943
|
+
});
|
|
918
944
|
throw new core_1.AugustSDKError('UNKNOWN', `Deposit native failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { wrapperAddress, receiver, amount } });
|
|
919
945
|
}
|
|
920
946
|
}
|
|
@@ -988,7 +1014,13 @@ async function rwaRedeemAsset(signer, options) {
|
|
|
988
1014
|
}
|
|
989
1015
|
if (e instanceof core_1.AugustSDKError)
|
|
990
1016
|
throw e;
|
|
991
|
-
|
|
1017
|
+
// User-cancelled RWA redeems are normal; only genuine failures stay at error.
|
|
1018
|
+
(0, core_1.logChainError)('rwaRedeemAsset', e, (0, core_1.isUserRejectionError)(e), {
|
|
1019
|
+
target,
|
|
1020
|
+
asset,
|
|
1021
|
+
amount,
|
|
1022
|
+
minOut,
|
|
1023
|
+
});
|
|
992
1024
|
throw new core_1.AugustSDKError('UNKNOWN', `RWA redeem failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { target, asset, amount, minOut } });
|
|
993
1025
|
}
|
|
994
1026
|
}
|
|
@@ -1040,6 +1072,22 @@ async function dispatchViaSwapRouter(args) {
|
|
|
1040
1072
|
abi: abis_1.ABI_ERC20,
|
|
1041
1073
|
});
|
|
1042
1074
|
const underlyingDecimals = Number(await underlyingErc20.decimals());
|
|
1075
|
+
// The on-chain SwapRouter only authorizes a specific (router, selector) pair
|
|
1076
|
+
// per chain (see SWAP_ROUTER_DEX_AGGREGATOR). Pin the aggregator to that
|
|
1077
|
+
// router's single generic method so the calldata selector is deterministic,
|
|
1078
|
+
// then reject any quote that would not match — otherwise the deposit reverts
|
|
1079
|
+
// on-chain with InvalidRouter() / InvalidNotWhitelisted() after the user has
|
|
1080
|
+
// already paid gas.
|
|
1081
|
+
const aggregator = core_1.SWAP_ROUTER_DEX_AGGREGATOR[args.chainId];
|
|
1082
|
+
if (!aggregator) {
|
|
1083
|
+
throw new core_1.AugustValidationError('INVALID_CHAIN', `vaultDeposit (SwapRouter): no DEX aggregator is configured for chainId ${args.chainId}, but a swap is required because the deposit asset (${args.actualDepositAsset}) differs from the vault's reference asset (${args.underlyingAsset}). Deposit the reference asset directly, or add a SWAP_ROUTER_DEX_AGGREGATOR entry once the router is whitelisted on-chain.`, {
|
|
1084
|
+
context: {
|
|
1085
|
+
chainId: args.chainId,
|
|
1086
|
+
depositAsset: args.actualDepositAsset,
|
|
1087
|
+
underlyingAsset: args.underlyingAsset,
|
|
1088
|
+
},
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1043
1091
|
const quote = await (0, swap_quotes_1.fetchSwapQuote)({
|
|
1044
1092
|
chainId: args.chainId,
|
|
1045
1093
|
srcToken: args.actualDepositAsset,
|
|
@@ -1049,7 +1097,25 @@ async function dispatchViaSwapRouter(args) {
|
|
|
1049
1097
|
amount: amountRaw,
|
|
1050
1098
|
receiver: args.routerAddress,
|
|
1051
1099
|
slippageBps: args.slippageBps,
|
|
1100
|
+
contractMethod: aggregator.contractMethod,
|
|
1052
1101
|
});
|
|
1102
|
+
// Fail closed on off-chain/on-chain config drift: if the aggregator's quote
|
|
1103
|
+
// targets a router or selector the deployed SwapRouter has not whitelisted,
|
|
1104
|
+
// the swapAndDeposit call would revert. Surfacing it here turns a wasted gas
|
|
1105
|
+
// burn into an actionable SDK error.
|
|
1106
|
+
const quotedSelector = quote.payload.slice(0, 10).toLowerCase();
|
|
1107
|
+
if (quote.router.toLowerCase() !== aggregator.router.toLowerCase() ||
|
|
1108
|
+
quotedSelector !== aggregator.selector.toLowerCase()) {
|
|
1109
|
+
throw new core_1.AugustValidationError('INVALID_INPUT', `vaultDeposit (SwapRouter): the aggregator quote (router ${quote.router}, selector ${quotedSelector}) does not match the router whitelisted on chain ${args.chainId} (router ${aggregator.router}, selector ${aggregator.selector}); the on-chain SwapRouter would revert. This signals drift between the SDK's SWAP_ROUTER_DEX_AGGREGATOR and the deployed router's enableRouter config.`, {
|
|
1110
|
+
context: {
|
|
1111
|
+
chainId: args.chainId,
|
|
1112
|
+
quotedRouter: quote.router,
|
|
1113
|
+
quotedSelector,
|
|
1114
|
+
expectedRouter: aggregator.router,
|
|
1115
|
+
expectedSelector: aggregator.selector,
|
|
1116
|
+
},
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1053
1119
|
return swapAndDeposit(args.signer, {
|
|
1054
1120
|
chainId: args.chainId,
|
|
1055
1121
|
vault: args.target,
|
package/lib/polyfills.js
CHANGED
|
@@ -5,8 +5,8 @@ const buffer_1 = require("buffer");
|
|
|
5
5
|
if (typeof window !== 'undefined' && !window.Buffer) {
|
|
6
6
|
window.Buffer = buffer_1.Buffer;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
if (typeof
|
|
10
|
-
|
|
8
|
+
const globalRef = globalThis;
|
|
9
|
+
if (typeof globalRef !== 'undefined' && !globalRef.Buffer) {
|
|
10
|
+
globalRef.Buffer = buffer_1.Buffer;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=polyfills.js.map
|