@augustdigital/sdk 9.3.0 → 9.4.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/lib/adapters/evm/getters.js +40 -0
- package/lib/adapters/evm/index.d.ts +106 -2
- package/lib/adapters/evm/index.js +125 -0
- package/lib/adapters/solana/index.d.ts +12 -5
- package/lib/adapters/solana/index.js +12 -4
- package/lib/adapters/solana/pricing.d.ts +173 -0
- package/lib/adapters/solana/pricing.js +223 -0
- package/lib/adapters/solana/types.d.ts +45 -0
- package/lib/adapters/solana/vault.actions.d.ts +33 -8
- package/lib/adapters/solana/vault.actions.js +185 -28
- package/lib/adapters/stellar/actions.d.ts +2 -2
- package/lib/adapters/stellar/actions.js +2 -2
- package/lib/adapters/stellar/getters.d.ts +1 -1
- package/lib/adapters/stellar/getters.js +2 -2
- package/lib/adapters/stellar/index.d.ts +1 -1
- package/lib/adapters/stellar/index.js +1 -1
- package/lib/adapters/stellar/types.d.ts +1 -2
- package/lib/core/analytics/method-taxonomy.js +7 -0
- package/lib/core/analytics/version.d.ts +1 -1
- package/lib/core/analytics/version.js +1 -1
- package/lib/core/base.class.d.ts +2 -2
- package/lib/core/base.class.js +2 -2
- package/lib/core/constants/core.d.ts +17 -3
- package/lib/core/constants/core.js +17 -3
- package/lib/core/constants/vaults.js +4 -0
- package/lib/core/fetcher.js +112 -45
- package/lib/core/helpers/concurrency.d.ts +37 -0
- package/lib/core/helpers/concurrency.js +58 -0
- package/lib/core/helpers/core.d.ts +9 -0
- package/lib/core/helpers/core.js +47 -0
- package/lib/core/helpers/vaults.d.ts +1 -1
- package/lib/core/helpers/vaults.js +1 -1
- package/lib/core/helpers/web3.js +14 -1
- package/lib/core/logger/curator-alert.d.ts +2 -2
- package/lib/core/logger/curator-alert.js +2 -2
- package/lib/evm/methods/crossChainVaultRegistry.d.ts +2 -3
- package/lib/evm/methods/crossChainVaultRegistry.js +2 -3
- package/lib/evm/types/crossChain.d.ts +1 -1
- package/lib/main.d.ts +7 -5
- package/lib/main.js +7 -5
- package/lib/modules/vaults/getters.d.ts +10 -3
- package/lib/modules/vaults/getters.js +205 -71
- package/lib/modules/vaults/main.d.ts +4 -4
- package/lib/modules/vaults/main.js +7 -4
- package/lib/modules/vaults/read.actions.d.ts +181 -0
- package/lib/modules/vaults/read.actions.js +331 -36
- package/lib/modules/vaults/types.d.ts +13 -0
- package/lib/modules/vaults/utils.js +5 -1
- package/lib/modules/vaults/write.actions.d.ts +74 -6
- package/lib/modules/vaults/write.actions.js +133 -23
- package/lib/sdk.d.ts +9827 -9342
- package/lib/services/subgraph/schema.d.ts +1 -1
- package/lib/services/subgraph/schema.js +1 -1
- package/lib/types/pools.d.ts +1 -1
- package/lib/types/vaults.d.ts +4 -4
- package/package.json +1 -1
|
@@ -12,6 +12,12 @@ exports.previewRedeem = previewRedeem;
|
|
|
12
12
|
exports.allowance = allowance;
|
|
13
13
|
exports.balanceOf = balanceOf;
|
|
14
14
|
exports.maxDeposit = maxDeposit;
|
|
15
|
+
exports.getIdleLiquidity = getIdleLiquidity;
|
|
16
|
+
exports.lagDuration = lagDuration;
|
|
17
|
+
exports.getWithdrawalEpoch = getWithdrawalEpoch;
|
|
18
|
+
exports.getBurnableAmountByReceiver = getBurnableAmountByReceiver;
|
|
19
|
+
exports.getRequirementByDate = getRequirementByDate;
|
|
20
|
+
exports.getScheduledTransactionsByDate = getScheduledTransactionsByDate;
|
|
15
21
|
const abis_1 = require("../../abis");
|
|
16
22
|
const core_1 = require("../../core");
|
|
17
23
|
/**
|
|
@@ -271,40 +277,6 @@ async function previewRwaRedemption(signer, options) {
|
|
|
271
277
|
throw new Error(`Preview RWA redemption failed: ${e instanceof Error ? e.message : 'Unknown error'}`);
|
|
272
278
|
}
|
|
273
279
|
}
|
|
274
|
-
function toRawBigInt(value, label) {
|
|
275
|
-
if (typeof value === 'bigint')
|
|
276
|
-
return value;
|
|
277
|
-
if (typeof value === 'number') {
|
|
278
|
-
if (!Number.isFinite(value)) {
|
|
279
|
-
throw new core_1.AugustValidationError('INVALID_INPUT', `${label}: amount must be finite, got ${value}`);
|
|
280
|
-
}
|
|
281
|
-
if (value < 0) {
|
|
282
|
-
throw new core_1.AugustValidationError('INVALID_INPUT', `${label}: amount must be non-negative, got ${value}`);
|
|
283
|
-
}
|
|
284
|
-
if (!Number.isSafeInteger(value)) {
|
|
285
|
-
throw new core_1.AugustValidationError('INVALID_INPUT', `${label}: amount ${value} exceeds Number.MAX_SAFE_INTEGER; pass a string or bigint to preserve precision`);
|
|
286
|
-
}
|
|
287
|
-
return BigInt(value);
|
|
288
|
-
}
|
|
289
|
-
if (typeof value === 'string') {
|
|
290
|
-
if (value.trim() === '') {
|
|
291
|
-
throw new core_1.AugustValidationError('INVALID_INPUT', `${label}: amount string must not be empty`);
|
|
292
|
-
}
|
|
293
|
-
try {
|
|
294
|
-
const parsed = BigInt(value);
|
|
295
|
-
if (parsed < 0n) {
|
|
296
|
-
throw new core_1.AugustValidationError('INVALID_INPUT', `${label}: amount must be non-negative, got ${value}`);
|
|
297
|
-
}
|
|
298
|
-
return parsed;
|
|
299
|
-
}
|
|
300
|
-
catch (e) {
|
|
301
|
-
if (e instanceof core_1.AugustValidationError)
|
|
302
|
-
throw e;
|
|
303
|
-
throw new core_1.AugustValidationError('INVALID_INPUT', `${label}: amount "${value}" is not a valid integer`);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
throw new core_1.AugustValidationError('INVALID_INPUT', `${label}: amount must be a string, bigint, or number`);
|
|
307
|
-
}
|
|
308
280
|
/**
|
|
309
281
|
* Preview the number of shares that would be minted for a deposit, without
|
|
310
282
|
* touching on-chain state. Routes between single-asset ERC-4626 and EVM-2
|
|
@@ -327,7 +299,7 @@ async function previewDeposit(signer, options) {
|
|
|
327
299
|
if (!(0, core_1.checkAddress)(vault, console, 'contract')) {
|
|
328
300
|
throw new core_1.AugustValidationError('INVALID_ADDRESS', `previewDeposit: invalid vault address ${vault}`);
|
|
329
301
|
}
|
|
330
|
-
const amountRaw = toRawBigInt(amount, 'previewDeposit');
|
|
302
|
+
const amountRaw = (0, core_1.toRawBigInt)(amount, 'previewDeposit');
|
|
331
303
|
try {
|
|
332
304
|
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vault))?.[0];
|
|
333
305
|
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
@@ -389,7 +361,7 @@ async function previewRedeem(signer, options) {
|
|
|
389
361
|
if (!(0, core_1.checkAddress)(vault, console, 'contract')) {
|
|
390
362
|
throw new core_1.AugustValidationError('INVALID_ADDRESS', `previewRedeem: invalid vault address ${vault}`);
|
|
391
363
|
}
|
|
392
|
-
const sharesRaw = toRawBigInt(shares, 'previewRedeem');
|
|
364
|
+
const sharesRaw = (0, core_1.toRawBigInt)(shares, 'previewRedeem');
|
|
393
365
|
try {
|
|
394
366
|
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vault))?.[0];
|
|
395
367
|
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
@@ -593,4 +565,327 @@ async function maxDeposit(signer, options) {
|
|
|
593
565
|
throw new core_1.AugustSDKError('UNKNOWN', `maxDeposit failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault, receiver } });
|
|
594
566
|
}
|
|
595
567
|
}
|
|
568
|
+
/**
|
|
569
|
+
* Read an EVM-2 vault's idle (uncommitted) liquidity — the balance available
|
|
570
|
+
* to satisfy an instant redemption without a synchronous recall from the
|
|
571
|
+
* settlement module, computed as `getTotalAssets() - externalAssets()`.
|
|
572
|
+
*
|
|
573
|
+
* EVM-2 only. Two on-chain reads with no caching — call it immediately
|
|
574
|
+
* before sizing an instant redemption rather than reusing a stale value, and
|
|
575
|
+
* size the redemption against the result rather than against total assets.
|
|
576
|
+
*
|
|
577
|
+
* @returns Idle liquidity, in the vault's reference-asset raw units.
|
|
578
|
+
* @throws AugustValidationError on invalid vault address or a non-EVM-2 vault.
|
|
579
|
+
* @throws AugustSDKError when either underlying contract read fails.
|
|
580
|
+
*
|
|
581
|
+
* @worstCaseRpcCalls 3 — vault-version lookup, `getTotalAssets`, `externalAssets`.
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* ```ts
|
|
585
|
+
* const idle = await augustSdk.evm.getIdleLiquidity({ vault: vaultAddress });
|
|
586
|
+
* if (redeemAmount > idle) {
|
|
587
|
+
* // fall back to a queued withdrawal instead of an instant one
|
|
588
|
+
* }
|
|
589
|
+
* ```
|
|
590
|
+
*/
|
|
591
|
+
async function getIdleLiquidity(signer, options) {
|
|
592
|
+
const { vault } = options;
|
|
593
|
+
if (!(0, core_1.checkAddress)(vault, console, 'contract')) {
|
|
594
|
+
throw new core_1.AugustValidationError('INVALID_ADDRESS', `getIdleLiquidity: invalid vault address ${vault}`);
|
|
595
|
+
}
|
|
596
|
+
try {
|
|
597
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vault))?.[0];
|
|
598
|
+
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
599
|
+
if (vaultVersion !== 'evm-2') {
|
|
600
|
+
throw new core_1.AugustValidationError('INVALID_INPUT', `getIdleLiquidity: only EVM-2 (Tokenized Vault V2) vaults expose externalAssets() — ${vault} resolved to ${vaultVersion}`);
|
|
601
|
+
}
|
|
602
|
+
const contract = (0, core_1.createContract)({
|
|
603
|
+
address: vault,
|
|
604
|
+
provider: signer,
|
|
605
|
+
abi: abis_1.ABI_TOKENIZED_VAULT_V2,
|
|
606
|
+
});
|
|
607
|
+
const [totalAssets, externalAssets] = await Promise.all([
|
|
608
|
+
contract.getTotalAssets(),
|
|
609
|
+
contract.externalAssets(),
|
|
610
|
+
]);
|
|
611
|
+
return BigInt(totalAssets) - BigInt(externalAssets);
|
|
612
|
+
}
|
|
613
|
+
catch (e) {
|
|
614
|
+
if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
|
|
615
|
+
throw e;
|
|
616
|
+
}
|
|
617
|
+
(0, core_1.logChainError)('getIdleLiquidity', e, (0, core_1.isExpectedRevertError)(e), { vault });
|
|
618
|
+
throw new core_1.AugustSDKError('UNKNOWN', `getIdleLiquidity failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault } });
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Read an EVM-2 vault's queued-withdrawal lag — the delay, in seconds,
|
|
623
|
+
* between `requestRedeem` and the withdrawal epoch becoming claimable.
|
|
624
|
+
*
|
|
625
|
+
* EVM-2 only. This value is per-vault (259,200s / 3 days on sentUSD, but
|
|
626
|
+
* shorter on other deployments) and can change after launch — read it live
|
|
627
|
+
* rather than hardcoding it.
|
|
628
|
+
*
|
|
629
|
+
* @returns Lag duration, in seconds.
|
|
630
|
+
* @throws AugustValidationError on invalid vault address or a non-EVM-2 vault.
|
|
631
|
+
* @throws AugustSDKError when the underlying contract read fails.
|
|
632
|
+
*
|
|
633
|
+
* @worstCaseRpcCalls 2 — vault-version lookup, `lagDuration`.
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```ts
|
|
637
|
+
* const seconds = await augustSdk.evm.lagDuration({ vault: vaultAddress });
|
|
638
|
+
* ```
|
|
639
|
+
*/
|
|
640
|
+
async function lagDuration(signer, options) {
|
|
641
|
+
const { vault } = options;
|
|
642
|
+
if (!(0, core_1.checkAddress)(vault, console, 'contract')) {
|
|
643
|
+
throw new core_1.AugustValidationError('INVALID_ADDRESS', `lagDuration: invalid vault address ${vault}`);
|
|
644
|
+
}
|
|
645
|
+
try {
|
|
646
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vault))?.[0];
|
|
647
|
+
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
648
|
+
if (vaultVersion !== 'evm-2') {
|
|
649
|
+
throw new core_1.AugustValidationError('INVALID_INPUT', `lagDuration: only EVM-2 (Tokenized Vault V2) vaults are supported by this wrapper — ${vault} resolved to ${vaultVersion}`);
|
|
650
|
+
}
|
|
651
|
+
const contract = (0, core_1.createContract)({
|
|
652
|
+
address: vault,
|
|
653
|
+
provider: signer,
|
|
654
|
+
abi: abis_1.ABI_TOKENIZED_VAULT_V2,
|
|
655
|
+
});
|
|
656
|
+
const raw = (await contract.lagDuration());
|
|
657
|
+
return BigInt(raw);
|
|
658
|
+
}
|
|
659
|
+
catch (e) {
|
|
660
|
+
if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
|
|
661
|
+
throw e;
|
|
662
|
+
}
|
|
663
|
+
(0, core_1.logChainError)('lagDuration', e, (0, core_1.isExpectedRevertError)(e), { vault });
|
|
664
|
+
throw new core_1.AugustSDKError('UNKNOWN', `lagDuration failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault } });
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Read an EVM-2 vault's current withdrawal epoch.
|
|
669
|
+
*
|
|
670
|
+
* The on-chain return order is `(year, month, day, claimableEpoch)` —
|
|
671
|
+
* `claimableEpoch` last, not first. This is the opposite order from what
|
|
672
|
+
* `requestRedeem` returns (`(claimableEpoch, year, month, day)`, epoch
|
|
673
|
+
* first); treat that call's return value, not this one, as the source of
|
|
674
|
+
* truth for a specific withdrawal's claim date.
|
|
675
|
+
*
|
|
676
|
+
* @returns The vault's current withdrawal epoch, by named field.
|
|
677
|
+
* @throws AugustValidationError on invalid vault address or a non-EVM-2 vault.
|
|
678
|
+
* @throws AugustSDKError when the underlying contract read fails.
|
|
679
|
+
*
|
|
680
|
+
* @worstCaseRpcCalls 2 — vault-version lookup, `getWithdrawalEpoch`.
|
|
681
|
+
*
|
|
682
|
+
* @example
|
|
683
|
+
* ```ts
|
|
684
|
+
* const { year, month, day, claimableEpoch } = await augustSdk.evm.getWithdrawalEpoch({
|
|
685
|
+
* vault: vaultAddress,
|
|
686
|
+
* });
|
|
687
|
+
* ```
|
|
688
|
+
*/
|
|
689
|
+
async function getWithdrawalEpoch(signer, options) {
|
|
690
|
+
const { vault } = options;
|
|
691
|
+
if (!(0, core_1.checkAddress)(vault, console, 'contract')) {
|
|
692
|
+
throw new core_1.AugustValidationError('INVALID_ADDRESS', `getWithdrawalEpoch: invalid vault address ${vault}`);
|
|
693
|
+
}
|
|
694
|
+
try {
|
|
695
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vault))?.[0];
|
|
696
|
+
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
697
|
+
if (vaultVersion !== 'evm-2') {
|
|
698
|
+
throw new core_1.AugustValidationError('INVALID_INPUT', `getWithdrawalEpoch: only EVM-2 (Tokenized Vault V2) vaults are supported by this wrapper — ${vault} resolved to ${vaultVersion}`);
|
|
699
|
+
}
|
|
700
|
+
const contract = (0, core_1.createContract)({
|
|
701
|
+
address: vault,
|
|
702
|
+
provider: signer,
|
|
703
|
+
abi: abis_1.ABI_TOKENIZED_VAULT_V2,
|
|
704
|
+
});
|
|
705
|
+
const [year, month, day, claimableEpoch] = (await contract.getWithdrawalEpoch());
|
|
706
|
+
return {
|
|
707
|
+
year: BigInt(year),
|
|
708
|
+
month: BigInt(month),
|
|
709
|
+
day: BigInt(day),
|
|
710
|
+
claimableEpoch: BigInt(claimableEpoch),
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
catch (e) {
|
|
714
|
+
if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
|
|
715
|
+
throw e;
|
|
716
|
+
}
|
|
717
|
+
(0, core_1.logChainError)('getWithdrawalEpoch', e, (0, core_1.isExpectedRevertError)(e), {
|
|
718
|
+
vault,
|
|
719
|
+
});
|
|
720
|
+
throw new core_1.AugustSDKError('UNKNOWN', `getWithdrawalEpoch failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault } });
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Read how much of a withdrawal-epoch date's queue a given receiver can
|
|
725
|
+
* currently claim via `claim`, before sending the claim transaction.
|
|
726
|
+
*
|
|
727
|
+
* EVM-2 only.
|
|
728
|
+
*
|
|
729
|
+
* @returns The claimable amount, in share-token raw units.
|
|
730
|
+
* @throws AugustValidationError on invalid address input or a non-EVM-2 vault.
|
|
731
|
+
* @throws AugustSDKError when the underlying contract read fails.
|
|
732
|
+
*
|
|
733
|
+
* @worstCaseRpcCalls 2 — vault-version lookup, `getBurnableAmountByReceiver`.
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* ```ts
|
|
737
|
+
* const claimable = await augustSdk.evm.getBurnableAmountByReceiver({
|
|
738
|
+
* vault: vaultAddress,
|
|
739
|
+
* receiver: walletAddress,
|
|
740
|
+
* year, month, day,
|
|
741
|
+
* });
|
|
742
|
+
* ```
|
|
743
|
+
*/
|
|
744
|
+
async function getBurnableAmountByReceiver(signer, options) {
|
|
745
|
+
const { vault, year, month, day, receiver } = options;
|
|
746
|
+
if (!(0, core_1.checkAddress)(vault, console, 'contract')) {
|
|
747
|
+
throw new core_1.AugustValidationError('INVALID_ADDRESS', `getBurnableAmountByReceiver: invalid vault address ${vault}`);
|
|
748
|
+
}
|
|
749
|
+
if (!(0, core_1.checkAddress)(receiver, console, 'wallet')) {
|
|
750
|
+
throw new core_1.AugustValidationError('INVALID_ADDRESS', `getBurnableAmountByReceiver: invalid receiver address ${receiver}`);
|
|
751
|
+
}
|
|
752
|
+
const yearRaw = (0, core_1.toRawBigInt)(year, 'getBurnableAmountByReceiver', 'year');
|
|
753
|
+
const monthRaw = (0, core_1.toRawBigInt)(month, 'getBurnableAmountByReceiver', 'month');
|
|
754
|
+
const dayRaw = (0, core_1.toRawBigInt)(day, 'getBurnableAmountByReceiver', 'day');
|
|
755
|
+
try {
|
|
756
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vault))?.[0];
|
|
757
|
+
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
758
|
+
if (vaultVersion !== 'evm-2') {
|
|
759
|
+
throw new core_1.AugustValidationError('INVALID_INPUT', `getBurnableAmountByReceiver: only EVM-2 (Tokenized Vault V2) vaults are supported by this wrapper — ${vault} resolved to ${vaultVersion}`);
|
|
760
|
+
}
|
|
761
|
+
const contract = (0, core_1.createContract)({
|
|
762
|
+
address: vault,
|
|
763
|
+
provider: signer,
|
|
764
|
+
abi: abis_1.ABI_TOKENIZED_VAULT_V2,
|
|
765
|
+
});
|
|
766
|
+
const raw = (await contract.getBurnableAmountByReceiver(yearRaw, monthRaw, dayRaw, receiver));
|
|
767
|
+
return BigInt(raw);
|
|
768
|
+
}
|
|
769
|
+
catch (e) {
|
|
770
|
+
if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
|
|
771
|
+
throw e;
|
|
772
|
+
}
|
|
773
|
+
(0, core_1.logChainError)('getBurnableAmountByReceiver', e, (0, core_1.isExpectedRevertError)(e), {
|
|
774
|
+
vault,
|
|
775
|
+
year,
|
|
776
|
+
month,
|
|
777
|
+
day,
|
|
778
|
+
receiver,
|
|
779
|
+
});
|
|
780
|
+
throw new core_1.AugustSDKError('UNKNOWN', `getBurnableAmountByReceiver failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault, year, month, day, receiver } });
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Read the total shares required to settle a withdrawal-epoch date's entire
|
|
785
|
+
* queue.
|
|
786
|
+
*
|
|
787
|
+
* EVM-2 only.
|
|
788
|
+
*
|
|
789
|
+
* @returns Required shares, in share-token raw units.
|
|
790
|
+
* @throws AugustValidationError on invalid vault address or a non-EVM-2 vault.
|
|
791
|
+
* @throws AugustSDKError when the underlying contract read fails.
|
|
792
|
+
*
|
|
793
|
+
* @worstCaseRpcCalls 2 — vault-version lookup, `getRequirementByDate`.
|
|
794
|
+
*
|
|
795
|
+
* @example
|
|
796
|
+
* ```ts
|
|
797
|
+
* const shares = await augustSdk.evm.getRequirementByDate({
|
|
798
|
+
* vault: vaultAddress,
|
|
799
|
+
* year, month, day,
|
|
800
|
+
* });
|
|
801
|
+
* ```
|
|
802
|
+
*/
|
|
803
|
+
async function getRequirementByDate(signer, options) {
|
|
804
|
+
const { vault, year, month, day } = options;
|
|
805
|
+
if (!(0, core_1.checkAddress)(vault, console, 'contract')) {
|
|
806
|
+
throw new core_1.AugustValidationError('INVALID_ADDRESS', `getRequirementByDate: invalid vault address ${vault}`);
|
|
807
|
+
}
|
|
808
|
+
const yearRaw = (0, core_1.toRawBigInt)(year, 'getRequirementByDate', 'year');
|
|
809
|
+
const monthRaw = (0, core_1.toRawBigInt)(month, 'getRequirementByDate', 'month');
|
|
810
|
+
const dayRaw = (0, core_1.toRawBigInt)(day, 'getRequirementByDate', 'day');
|
|
811
|
+
try {
|
|
812
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vault))?.[0];
|
|
813
|
+
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
814
|
+
if (vaultVersion !== 'evm-2') {
|
|
815
|
+
throw new core_1.AugustValidationError('INVALID_INPUT', `getRequirementByDate: only EVM-2 (Tokenized Vault V2) vaults are supported by this wrapper — ${vault} resolved to ${vaultVersion}`);
|
|
816
|
+
}
|
|
817
|
+
const contract = (0, core_1.createContract)({
|
|
818
|
+
address: vault,
|
|
819
|
+
provider: signer,
|
|
820
|
+
abi: abis_1.ABI_TOKENIZED_VAULT_V2,
|
|
821
|
+
});
|
|
822
|
+
const raw = (await contract.getRequirementByDate(yearRaw, monthRaw, dayRaw));
|
|
823
|
+
return BigInt(raw);
|
|
824
|
+
}
|
|
825
|
+
catch (e) {
|
|
826
|
+
if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
|
|
827
|
+
throw e;
|
|
828
|
+
}
|
|
829
|
+
(0, core_1.logChainError)('getRequirementByDate', e, (0, core_1.isExpectedRevertError)(e), {
|
|
830
|
+
vault,
|
|
831
|
+
year,
|
|
832
|
+
month,
|
|
833
|
+
day,
|
|
834
|
+
});
|
|
835
|
+
throw new core_1.AugustSDKError('UNKNOWN', `getRequirementByDate failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault, year, month, day } });
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Read the scheduled queued-withdrawal volume for a withdrawal-epoch date.
|
|
840
|
+
*
|
|
841
|
+
* EVM-2 only.
|
|
842
|
+
*
|
|
843
|
+
* @returns Total scheduled transactions and their execution epoch.
|
|
844
|
+
* @throws AugustValidationError on invalid vault address or a non-EVM-2 vault.
|
|
845
|
+
* @throws AugustSDKError when the underlying contract read fails.
|
|
846
|
+
*
|
|
847
|
+
* @worstCaseRpcCalls 2 — vault-version lookup, `getScheduledTransactionsByDate`.
|
|
848
|
+
*
|
|
849
|
+
* @example
|
|
850
|
+
* ```ts
|
|
851
|
+
* const { totalTransactions, executionEpoch } =
|
|
852
|
+
* await augustSdk.evm.getScheduledTransactionsByDate({
|
|
853
|
+
* vault: vaultAddress,
|
|
854
|
+
* year, month, day,
|
|
855
|
+
* });
|
|
856
|
+
* ```
|
|
857
|
+
*/
|
|
858
|
+
async function getScheduledTransactionsByDate(signer, options) {
|
|
859
|
+
const { vault, year, month, day } = options;
|
|
860
|
+
if (!(0, core_1.checkAddress)(vault, console, 'contract')) {
|
|
861
|
+
throw new core_1.AugustValidationError('INVALID_ADDRESS', `getScheduledTransactionsByDate: invalid vault address ${vault}`);
|
|
862
|
+
}
|
|
863
|
+
const yearRaw = (0, core_1.toRawBigInt)(year, 'getScheduledTransactionsByDate', 'year');
|
|
864
|
+
const monthRaw = (0, core_1.toRawBigInt)(month, 'getScheduledTransactionsByDate', 'month');
|
|
865
|
+
const dayRaw = (0, core_1.toRawBigInt)(day, 'getScheduledTransactionsByDate', 'day');
|
|
866
|
+
try {
|
|
867
|
+
const tokenizedVault = (await (0, core_1.fetchTokenizedVault)(vault))?.[0];
|
|
868
|
+
const vaultVersion = (0, core_1.getVaultVersionV2)(tokenizedVault);
|
|
869
|
+
if (vaultVersion !== 'evm-2') {
|
|
870
|
+
throw new core_1.AugustValidationError('INVALID_INPUT', `getScheduledTransactionsByDate: only EVM-2 (Tokenized Vault V2) vaults are supported by this wrapper — ${vault} resolved to ${vaultVersion}`);
|
|
871
|
+
}
|
|
872
|
+
const contract = (0, core_1.createContract)({
|
|
873
|
+
address: vault,
|
|
874
|
+
provider: signer,
|
|
875
|
+
abi: abis_1.ABI_TOKENIZED_VAULT_V2,
|
|
876
|
+
});
|
|
877
|
+
const [totalTransactions, executionEpoch] = (await contract.getScheduledTransactionsByDate(yearRaw, monthRaw, dayRaw));
|
|
878
|
+
return {
|
|
879
|
+
totalTransactions: BigInt(totalTransactions),
|
|
880
|
+
executionEpoch: BigInt(executionEpoch),
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
catch (e) {
|
|
884
|
+
if (e instanceof core_1.AugustValidationError || e instanceof core_1.AugustSDKError) {
|
|
885
|
+
throw e;
|
|
886
|
+
}
|
|
887
|
+
(0, core_1.logChainError)('getScheduledTransactionsByDate', e, (0, core_1.isExpectedRevertError)(e), { vault, year, month, day });
|
|
888
|
+
throw new core_1.AugustSDKError('UNKNOWN', `getScheduledTransactionsByDate failed: ${e instanceof Error ? e.message : 'Unknown error'}`, { cause: e, context: { vault, year, month, day } });
|
|
889
|
+
}
|
|
890
|
+
}
|
|
596
891
|
//# sourceMappingURL=read.actions.js.map
|
|
@@ -68,6 +68,19 @@ export interface IVaultCustomOptions {
|
|
|
68
68
|
wallet?: IAddress;
|
|
69
69
|
solanaWallet?: string;
|
|
70
70
|
stellarWallet?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Portfolio mode for a SINGLE vault read: when true, a `closed` +
|
|
73
|
+
* `is_visible: false` vault resolves normally instead of coming back as
|
|
74
|
+
* null. Needed by any caller reading ONE vault by address on behalf of a
|
|
75
|
+
* holder — a position in a closed vault must still resolve its metadata, or
|
|
76
|
+
* the holder is left with no way to act on it.
|
|
77
|
+
*
|
|
78
|
+
* The plural counterpart is {@link IGetVaultsOptions.includeClosed}; this is
|
|
79
|
+
* the same flag on the per-address path.
|
|
80
|
+
*
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
includeClosed?: boolean;
|
|
71
84
|
}
|
|
72
85
|
/**
|
|
73
86
|
* Options accepted by `getVaults` — on both the `AugustSDK` facade and the
|
|
@@ -524,7 +524,11 @@ async function buildFormattedVault(provider, tokenizedVault, contractCalls) {
|
|
|
524
524
|
isVisible: tokenizedVault.is_visible,
|
|
525
525
|
reserveTarget: tokenizedVault.reserve_target,
|
|
526
526
|
reserveTolerance: tokenizedVault.reserve_tolerance,
|
|
527
|
-
|
|
527
|
+
// On-chain pause first, then the hardcoded deny list — a vault can be
|
|
528
|
+
// withheld from deposits for either reason and the list is not a substitute
|
|
529
|
+
// for reading the contract.
|
|
530
|
+
isDepositPaused: contractCalls.depositsPaused === true ||
|
|
531
|
+
(0, vaults_1.isBadVault)(tokenizedVault.address),
|
|
528
532
|
decimals: contractCalls.decimals,
|
|
529
533
|
isWithdrawalPaused: contractCalls.withdrawalsPaused,
|
|
530
534
|
idleAssets: (0, core_1.toNormalizedBn)(await getIdleAssets(provider, tokenizedVault.address, contractCalls.asset, contractCalls.totalAssets,
|
|
@@ -275,12 +275,14 @@ export declare function approve(signer: Signer | Wallet, options: IContractWrite
|
|
|
275
275
|
export declare function vaultDeposit(signer: Signer | Wallet, options: IContractWriteOptions): Promise<string>;
|
|
276
276
|
/**
|
|
277
277
|
* Request to redeem vault shares. For EVM-1 vaults this queues a standard
|
|
278
|
-
* redemption (claimable later via `vaultRedeem`)
|
|
279
|
-
*
|
|
280
|
-
*
|
|
278
|
+
* redemption (claimable later via `vaultRedeem`). For EVM-2 vaults the queued
|
|
279
|
+
* `requestRedeem` escrows the shares in the vault via `transferFrom`, so this
|
|
280
|
+
* also approves the receipt token when its allowance is short; the instant
|
|
281
|
+
* path (`isInstantRedeem: true`) burns the caller's shares directly and sends
|
|
282
|
+
* no approval.
|
|
281
283
|
*
|
|
282
|
-
*
|
|
283
|
-
* redeem call, regardless of the caller's `wait` flag.
|
|
284
|
+
* The receipt-token approval (EVM-2 queued path) is always waited on before
|
|
285
|
+
* the redeem call, regardless of the caller's `wait` flag.
|
|
284
286
|
*
|
|
285
287
|
* @param signer ethers Signer / Wallet (or viem WalletClient via {@link setSigner})
|
|
286
288
|
* @param options Vault address, wallet, amount, optional `isInstantRedeem`,
|
|
@@ -311,7 +313,6 @@ export declare function vaultDeposit(signer: Signer | Wallet, options: IContract
|
|
|
311
313
|
*/
|
|
312
314
|
export declare function vaultRequestRedeem(signer: Signer | Wallet, options: IContractWriteOptions): Promise<string>;
|
|
313
315
|
/**
|
|
314
|
-
* @TODO
|
|
315
316
|
* @description withdraw funds from the specified pool including accrued rewards
|
|
316
317
|
* @param signer signer / wallet object
|
|
317
318
|
* @param options object including pool contract address, user wallet address, and more
|
|
@@ -323,6 +324,73 @@ export declare function vaultRedeem(signer: Signer | Wallet, options: IContractW
|
|
|
323
324
|
day: string;
|
|
324
325
|
receiverIndex: string;
|
|
325
326
|
}): Promise<string>;
|
|
327
|
+
/** Options for {@link claimWithdrawal}. */
|
|
328
|
+
export type IClaimWithdrawalOptions = {
|
|
329
|
+
/** EVM-2 (Tokenized Vault V2) vault contract address. */
|
|
330
|
+
target: IAddress;
|
|
331
|
+
/**
|
|
332
|
+
* Wallet initiating the claim. Not a signer, but it is the default
|
|
333
|
+
* `receiver` of the withdrawn assets when `receiver` is omitted.
|
|
334
|
+
*/
|
|
335
|
+
wallet: IAddress;
|
|
336
|
+
/**
|
|
337
|
+
* Withdrawal-epoch year to settle, from the `(claimableEpoch, year, month,
|
|
338
|
+
* day)` tuple `vaultRequestRedeem`/`requestRedeem` returned for this
|
|
339
|
+
* withdrawal — do not re-derive it from a timestamp.
|
|
340
|
+
*/
|
|
341
|
+
year: string | bigint | number;
|
|
342
|
+
/** Withdrawal-epoch month, same source as `year`. */
|
|
343
|
+
month: string | bigint | number;
|
|
344
|
+
/** Withdrawal-epoch day, same source as `year`. */
|
|
345
|
+
day: string | bigint | number;
|
|
346
|
+
/** Address receiving the withdrawn assets. Defaults to `wallet`. */
|
|
347
|
+
receiver?: IAddress;
|
|
348
|
+
/** Wait for transaction confirmation. */
|
|
349
|
+
wait?: boolean;
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* Claim a previously-requested queued withdrawal on an EVM-2 (Tokenized
|
|
353
|
+
* Vault V2) vault, once its withdrawal epoch has passed.
|
|
354
|
+
*
|
|
355
|
+
* EVM-2 only — v1/v0 vaults use a different claim path ({@link vaultRedeem}).
|
|
356
|
+
* The vault's on-chain `claim(year, month, day, receiverAddr)` reverts if the
|
|
357
|
+
* epoch has not yet elapsed, or if the vault's idle reserve has not been
|
|
358
|
+
* refilled from subaccounts to cover the queue for that date; neither
|
|
359
|
+
* condition is checked client-side before sending.
|
|
360
|
+
*
|
|
361
|
+
* @param signer ethers Signer / Wallet.
|
|
362
|
+
* @param options.target EVM-2 vault contract address.
|
|
363
|
+
* @param options.wallet Wallet initiating the claim; receives the withdrawn assets unless `receiver` is set.
|
|
364
|
+
* @param options.year Withdrawal-epoch year from `requestRedeem`.
|
|
365
|
+
* @param options.month Withdrawal-epoch month from `requestRedeem`.
|
|
366
|
+
* @param options.day Withdrawal-epoch day from `requestRedeem`.
|
|
367
|
+
* @param options.receiver Address receiving the withdrawn assets. Defaults to `wallet`.
|
|
368
|
+
* @param options.wait Wait for transaction confirmation.
|
|
369
|
+
* @returns Claim transaction hash.
|
|
370
|
+
* @throws AugustValidationError on invalid address input, missing or non-integer date fields, or a non-EVM-2 vault.
|
|
371
|
+
* @throws AugustSDKError when the on-chain claim call fails.
|
|
372
|
+
*
|
|
373
|
+
* @worstCaseRpcCalls 2 — one vault-version lookup, one claim transaction.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```ts
|
|
377
|
+
* const { year, month, day } = await augustSdk.evm.vaultRequestRedeem({
|
|
378
|
+
* target: vaultAddress,
|
|
379
|
+
* wallet: walletAddress,
|
|
380
|
+
* amount: '10',
|
|
381
|
+
* });
|
|
382
|
+
* // ...after the withdrawal epoch has elapsed...
|
|
383
|
+
* await augustSdk.evm.claimWithdrawal({
|
|
384
|
+
* target: vaultAddress,
|
|
385
|
+
* wallet: walletAddress,
|
|
386
|
+
* year,
|
|
387
|
+
* month,
|
|
388
|
+
* day,
|
|
389
|
+
* wait: true,
|
|
390
|
+
* });
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
export declare function claimWithdrawal(signer: Signer | Wallet, options: IClaimWithdrawalOptions): Promise<string>;
|
|
326
394
|
/**
|
|
327
395
|
* Deposit a native token (ETH / AVAX / etc.) into a vault via the
|
|
328
396
|
* `MultiAssetNativeDepositWrapper`. The wrapper forwards `msg.value` to
|