@augustdigital/sdk 8.6.1 → 8.7.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/index.d.ts +24 -1
- package/lib/adapters/evm/index.js +26 -0
- package/lib/adapters/solana/vault.actions.d.ts +18 -0
- package/lib/adapters/solana/vault.actions.js +43 -2
- 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/constants/swap-router.d.ts +26 -8
- package/lib/core/constants/swap-router.js +31 -15
- package/lib/core/helpers/swap-router.d.ts +16 -4
- package/lib/core/helpers/swap-router.js +19 -6
- package/lib/main.d.ts +26 -0
- package/lib/main.js +22 -0
- package/lib/modules/vaults/main.d.ts +46 -0
- package/lib/modules/vaults/main.js +71 -0
- package/lib/modules/vaults/write.actions.d.ts +51 -2
- package/lib/modules/vaults/write.actions.js +149 -44
- package/lib/sdk.d.ts +1158 -922
- package/lib/services/subgraph/vaults.d.ts +3 -1
- package/lib/services/subgraph/vaults.js +57 -11
- package/lib/types/vaults.d.ts +37 -0
- package/package.json +1 -1
|
@@ -19,5 +19,7 @@ export declare function getSubgraphAllWithdrawals(pool: IAddress, provider: ICon
|
|
|
19
19
|
withdrawalProcesseds: ISubgraphWithdrawProccessed[];
|
|
20
20
|
}>;
|
|
21
21
|
export declare function getSubgraphUserHistory(user: IAddress, provider: IContractRunner, pool: IAddress, slackWebookUrl?: string): Promise<ISubgraphUserHistoryItem[]>;
|
|
22
|
-
export declare function getSubgraphVaultHistory(provider: IContractRunner, pool: IAddress, slackWebookUrl?: string
|
|
22
|
+
export declare function getSubgraphVaultHistory(provider: IContractRunner, pool: IAddress, slackWebookUrl?: string, opts?: {
|
|
23
|
+
sinceTs?: number;
|
|
24
|
+
}): Promise<ISubgraphUserHistoryItem[]>;
|
|
23
25
|
export declare function getSubgraphUserTransfers(user: IAddress, provider: IContractRunner, pool: IAddress, slackWebookUrl?: string): Promise<ISubgraphTransfer[]>;
|
|
@@ -670,7 +670,7 @@ async function getSubgraphUserHistory(user, provider, pool, slackWebookUrl = sla
|
|
|
670
670
|
return [];
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
|
-
async function getSubgraphVaultHistory(provider, pool, slackWebookUrl = slack_1.DEFAULT_SLACK_WEBHOOK_URL) {
|
|
673
|
+
async function getSubgraphVaultHistory(provider, pool, slackWebookUrl = slack_1.DEFAULT_SLACK_WEBHOOK_URL, opts = {}) {
|
|
674
674
|
try {
|
|
675
675
|
// setup
|
|
676
676
|
const requests = [];
|
|
@@ -728,45 +728,91 @@ async function getSubgraphVaultHistory(provider, pool, slackWebookUrl = slack_1.
|
|
|
728
728
|
? EVM_V2_DEPOSIT_QUERY_PROPS
|
|
729
729
|
: DEPOSIT_QUERY_PROPS
|
|
730
730
|
: NEW_DEPOSIT_QUERY_PROPS;
|
|
731
|
-
|
|
731
|
+
// Each of the four event entities is capped at 1000 rows per request, so
|
|
732
|
+
// a busy vault would silently truncate. Page all four in lockstep on a
|
|
733
|
+
// shared `skip` cursor (rows are ordered newest-first) and keep going while
|
|
734
|
+
// any entity returned a full page. When `sinceTs` is set we can stop early:
|
|
735
|
+
// once an entity's oldest row in the page predates the window, no later
|
|
736
|
+
// page can contain in-window rows for it.
|
|
737
|
+
const PAGE_SIZE = 1000;
|
|
738
|
+
const accumulated = {
|
|
739
|
+
withdraws: [],
|
|
740
|
+
withdrawalRequesteds: [],
|
|
741
|
+
withdrawalProcesseds: [],
|
|
742
|
+
deposits: [],
|
|
743
|
+
};
|
|
744
|
+
let skip = 0;
|
|
745
|
+
for (;;) {
|
|
746
|
+
const result = await (0, fetcher_1.fetchSubgraph)(goldskyUrl, `{
|
|
732
747
|
withdraws (
|
|
733
|
-
first:
|
|
748
|
+
first: ${PAGE_SIZE},
|
|
749
|
+
skip: ${skip},
|
|
734
750
|
orderBy: ${orderByTimestamp},
|
|
735
751
|
orderDirection: desc,
|
|
736
752
|
) {
|
|
737
753
|
${withdrawProps}
|
|
738
754
|
}
|
|
739
755
|
withdrawalRequesteds (
|
|
740
|
-
first:
|
|
756
|
+
first: ${PAGE_SIZE},
|
|
757
|
+
skip: ${skip},
|
|
741
758
|
orderBy: ${orderByTimestamp},
|
|
742
759
|
orderDirection: desc,
|
|
743
760
|
) {
|
|
744
761
|
${withdrawalRequestedProps}
|
|
745
762
|
}
|
|
746
763
|
withdrawalProcesseds (
|
|
747
|
-
first:
|
|
764
|
+
first: ${PAGE_SIZE},
|
|
765
|
+
skip: ${skip},
|
|
748
766
|
orderBy: ${orderByTimestamp},
|
|
749
767
|
orderDirection: desc,
|
|
750
768
|
) {
|
|
751
769
|
${withdrawalProcessedProps}
|
|
752
770
|
}
|
|
753
771
|
deposits (
|
|
754
|
-
first:
|
|
772
|
+
first: ${PAGE_SIZE},
|
|
773
|
+
skip: ${skip},
|
|
755
774
|
orderBy: ${orderByTimestamp},
|
|
756
775
|
orderDirection: desc,
|
|
757
776
|
) {
|
|
758
777
|
${depositProps}
|
|
759
778
|
}
|
|
760
779
|
}`, GOLDSKY_API_KEY);
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
780
|
+
if (result.status !== 200) {
|
|
781
|
+
core_1.Logger.log.error('getSubgraphVaultHistory', new Error(`HTTP ${result.status} ${result.statusText}`), { status: result.status, statusText: result.statusText, skip });
|
|
782
|
+
// First page failed → nothing to return. A later page failing still
|
|
783
|
+
// yields whatever earlier pages accumulated.
|
|
784
|
+
if (skip === 0)
|
|
785
|
+
return requests;
|
|
786
|
+
break;
|
|
787
|
+
}
|
|
788
|
+
const json = (await result.json());
|
|
789
|
+
const page = json.data;
|
|
790
|
+
accumulated.withdraws.push(...(page?.withdraws ?? []));
|
|
791
|
+
accumulated.withdrawalRequesteds.push(...(page?.withdrawalRequesteds ?? []));
|
|
792
|
+
accumulated.withdrawalProcesseds.push(...(page?.withdrawalProcesseds ?? []));
|
|
793
|
+
accumulated.deposits.push(...(page?.deposits ?? []));
|
|
794
|
+
const entities = [
|
|
795
|
+
page?.withdraws,
|
|
796
|
+
page?.withdrawalRequesteds,
|
|
797
|
+
page?.withdrawalProcesseds,
|
|
798
|
+
page?.deposits,
|
|
799
|
+
];
|
|
800
|
+
const needMore = entities.some((rows) => {
|
|
801
|
+
if ((rows?.length ?? 0) < PAGE_SIZE)
|
|
802
|
+
return false;
|
|
803
|
+
if (opts.sinceTs === undefined)
|
|
804
|
+
return true;
|
|
805
|
+
const oldest = Number(rows?.[rows.length - 1]?.timestamp_);
|
|
806
|
+
return !Number.isFinite(oldest) || oldest >= opts.sinceTs;
|
|
807
|
+
});
|
|
808
|
+
if (!needMore)
|
|
809
|
+
break;
|
|
810
|
+
skip += PAGE_SIZE;
|
|
764
811
|
}
|
|
765
|
-
const json = (await result.json());
|
|
766
812
|
// Format data
|
|
767
813
|
const chainId = await (0, core_1.getChainId)(provider);
|
|
768
814
|
const decimals = await (0, core_1.getDecimals)(provider, pool);
|
|
769
|
-
const formattedRequests = sortUserHistory(
|
|
815
|
+
const formattedRequests = sortUserHistory(accumulated, chainId, decimals, pool);
|
|
770
816
|
return formattedRequests;
|
|
771
817
|
}
|
|
772
818
|
catch (e) {
|
package/lib/types/vaults.d.ts
CHANGED
|
@@ -524,3 +524,40 @@ export interface ISwapRouterNativeDepositOptions extends ISwapRouterBaseOptions
|
|
|
524
524
|
/** Native token amount in wei. Sent as `msg.value`. */
|
|
525
525
|
amount: bigint;
|
|
526
526
|
}
|
|
527
|
+
/**
|
|
528
|
+
* Options for {@link swapRouterDeposit} — the high-level, explicit SwapRouter
|
|
529
|
+
* deposit entry point. It reads the vault's reference asset and decimals
|
|
530
|
+
* on-chain, then picks the correct router path from `depositAsset`, so callers
|
|
531
|
+
* do not hand-build swap legs or pre-resolve decimals themselves.
|
|
532
|
+
*
|
|
533
|
+
* Prefer this over relying on the implicit routing inside `vaultDeposit`: here
|
|
534
|
+
* the caller opts into the SwapRouter deliberately, so a vault is never
|
|
535
|
+
* silently routed through a swap it does not need — the failure mode that broke
|
|
536
|
+
* native multi-asset deposits when a multi-asset vault was added to
|
|
537
|
+
* `VAULTS_USING_SWAP_ROUTER`.
|
|
538
|
+
*
|
|
539
|
+
* Unlike {@link ISwapRouterBaseOptions}, `receiver` is optional here and
|
|
540
|
+
* defaults to the signer's resolved EOA.
|
|
541
|
+
*/
|
|
542
|
+
export interface ISwapRouterDepositOptions extends Omit<ISwapRouterBaseOptions, 'receiver'> {
|
|
543
|
+
/**
|
|
544
|
+
* Token being deposited, held by the signer. Its relationship to the vault's
|
|
545
|
+
* reference asset selects the router path:
|
|
546
|
+
* - equals the reference asset → direct router deposit (no swap);
|
|
547
|
+
* - the zero address → native-token deposit (only when the reference asset
|
|
548
|
+
* is the chain's wrapped-native token);
|
|
549
|
+
* - any other ERC-20 → a swap to the reference asset via the chain's
|
|
550
|
+
* whitelisted DEX aggregator, bundled into the deposit.
|
|
551
|
+
*/
|
|
552
|
+
depositAsset: IAddress;
|
|
553
|
+
/** Amount in `depositAsset`'s smallest unit (decimal string or bigint). */
|
|
554
|
+
amount: string | bigint;
|
|
555
|
+
/** Address that receives the minted shares. Defaults to the signer's EOA. */
|
|
556
|
+
receiver?: IAddress;
|
|
557
|
+
/**
|
|
558
|
+
* Max slippage in basis points for the swap leg. Only used when `depositAsset`
|
|
559
|
+
* differs from the reference asset; passed through to the swap quote, whose
|
|
560
|
+
* own default applies when omitted.
|
|
561
|
+
*/
|
|
562
|
+
slippageBps?: number;
|
|
563
|
+
}
|