@augustdigital/sdk 8.6.0 → 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.
@@ -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): Promise<ISubgraphUserHistoryItem[]>;
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[]>;
@@ -183,12 +183,19 @@ const NEW_DEPOSIT_QUERY_PROPS = `
183
183
  senderAddr
184
184
  receiverAddr
185
185
  `;
186
+ // The `block_number: blockNumber` alias on these new-schema withdrawal prop
187
+ // sets is required, not cosmetic: getWithdrawalRequestsWithStatus prunes by
188
+ // `Number(req.block_number) >= blockCutoff` (per the ISubgraphBase contract).
189
+ // New-schema subgraphs expose the field as `blockNumber`, so without the alias
190
+ // it reads undefined → Number(undefined) is NaN → every request is pruned
191
+ // (AUGUST-6514). Only the REQUESTED set is read today; the processed/withdrawals
192
+ // aliases below are kept for the same type contract so the NaN prune can't recur.
186
193
  const NEW_WITHDRAWALS_REQUESTED_QUERY_PROPS = `
187
194
  id
188
195
  shares
189
196
  receiverAddr
190
197
  holderAddr
191
- blockNumber
198
+ block_number: blockNumber
192
199
  transactionHash_: transactionHash
193
200
  timestamp_: blockTimestamp
194
201
  `;
@@ -196,7 +203,7 @@ const NEW_WITHDRAWALS_PROCESSED_QUERY_PROPS = `
196
203
  id
197
204
  receiverAddr
198
205
  assetsAmount
199
- blockNumber
206
+ block_number: blockNumber
200
207
  transactionHash_: transactionHash
201
208
  timestamp_: blockTimestamp
202
209
  `;
@@ -204,7 +211,7 @@ const NEW_WITHDRAWALS_QUERY_PROPS = `
204
211
  id
205
212
  transactionHash_: transactionHash
206
213
  timestamp_: blockTimestamp
207
- blockNumber
214
+ block_number: blockNumber
208
215
  assets
209
216
  receiver
210
217
  sender
@@ -663,7 +670,7 @@ async function getSubgraphUserHistory(user, provider, pool, slackWebookUrl = sla
663
670
  return [];
664
671
  }
665
672
  }
666
- 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 = {}) {
667
674
  try {
668
675
  // setup
669
676
  const requests = [];
@@ -721,45 +728,91 @@ async function getSubgraphVaultHistory(provider, pool, slackWebookUrl = slack_1.
721
728
  ? EVM_V2_DEPOSIT_QUERY_PROPS
722
729
  : DEPOSIT_QUERY_PROPS
723
730
  : NEW_DEPOSIT_QUERY_PROPS;
724
- const result = await (0, fetcher_1.fetchSubgraph)(goldskyUrl, `{
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, `{
725
747
  withdraws (
726
- first: 1000,
748
+ first: ${PAGE_SIZE},
749
+ skip: ${skip},
727
750
  orderBy: ${orderByTimestamp},
728
751
  orderDirection: desc,
729
752
  ) {
730
753
  ${withdrawProps}
731
754
  }
732
755
  withdrawalRequesteds (
733
- first: 1000,
756
+ first: ${PAGE_SIZE},
757
+ skip: ${skip},
734
758
  orderBy: ${orderByTimestamp},
735
759
  orderDirection: desc,
736
760
  ) {
737
761
  ${withdrawalRequestedProps}
738
762
  }
739
763
  withdrawalProcesseds (
740
- first: 1000,
764
+ first: ${PAGE_SIZE},
765
+ skip: ${skip},
741
766
  orderBy: ${orderByTimestamp},
742
767
  orderDirection: desc,
743
768
  ) {
744
769
  ${withdrawalProcessedProps}
745
770
  }
746
771
  deposits (
747
- first: 1000,
772
+ first: ${PAGE_SIZE},
773
+ skip: ${skip},
748
774
  orderBy: ${orderByTimestamp},
749
775
  orderDirection: desc,
750
776
  ) {
751
777
  ${depositProps}
752
778
  }
753
779
  }`, GOLDSKY_API_KEY);
754
- if (result.status !== 200) {
755
- core_1.Logger.log.error('getSubgraphVaultHistory', new Error(`HTTP ${result.status} ${result.statusText}`), { status: result.status, statusText: result.statusText });
756
- return requests;
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;
757
811
  }
758
- const json = (await result.json());
759
812
  // Format data
760
813
  const chainId = await (0, core_1.getChainId)(provider);
761
814
  const decimals = await (0, core_1.getDecimals)(provider, pool);
762
- const formattedRequests = sortUserHistory(json.data, chainId, decimals, pool);
815
+ const formattedRequests = sortUserHistory(accumulated, chainId, decimals, pool);
763
816
  return formattedRequests;
764
817
  }
765
818
  catch (e) {
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augustdigital/sdk",
3
- "version": "8.6.0",
3
+ "version": "8.7.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/sdk.d.ts",
6
6
  "keywords": [