@aintivirus-ai/mixer-sdk 1.0.7 → 1.0.8

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.
@@ -1,5 +1,5 @@
1
1
  import type { AssetMode } from "../../types";
2
- import { type ClaimedEntity, type DepositEntity, type DepositOrderBy, type MixerPool, type MixerPoolOrderBy, type OrderDirection, type PaymentProcessedEntity, type PaymentStats, type ProtocolState, type TokenUpdatedEntity, type SeasonAssetEntity, type SeasonEntity, type StakedEntity, type SubgraphClientConfig, type UnstakedEntity, type WithdrawalEntity, type WithdrawalOrderBy } from "./types";
2
+ import { type ClaimedEntity, type DepositEntity, type DepositOrderBy, type MixerPool, type MixerPoolOrderBy, type OrderDirection, type PaymentProcessedEntity, type PaymentStats, type ProtocolState, type TokenUpdatedEntity, type SeasonAssetEntity, type SeasonEntity, type SeasonSummary, type SeasonWithParticipants, type StakedEntity, type SubgraphClientConfig, type UnstakedEntity, type WithdrawalEntity, type WithdrawalOrderBy } from "./types";
3
3
  export declare class AintiVirusEVMSubgraph {
4
4
  private readonly endpoint;
5
5
  private readonly fetch;
@@ -51,6 +51,18 @@ export declare class AintiVirusEVMSubgraph {
51
51
  orderDirection?: OrderDirection;
52
52
  }): Promise<WithdrawalEntity[]>;
53
53
  getSeason(seasonId: bigint): Promise<SeasonEntity | null>;
54
+ /**
55
+ * Get all seasons with TVL and rewards.
56
+ */
57
+ getAllSeasons(): Promise<SeasonSummary[]>;
58
+ /**
59
+ * Get season with participants (staker addresses and staked amounts).
60
+ */
61
+ getSeasonWithParticipants(seasonId: bigint): Promise<SeasonWithParticipants | null>;
62
+ /**
63
+ * Get protocol lifetime stats (id = "protocol").
64
+ */
65
+ getProtocolLifetimeStats(): Promise<ProtocolState | null>;
54
66
  getSeasonAssets(params?: {
55
67
  seasonId?: bigint;
56
68
  asset?: string;
@@ -58,6 +58,8 @@ class AintiVirusEVMSubgraph {
58
58
  withdrawalCount: (0, utils_1.asBigint)(p.withdrawalCount),
59
59
  totalStaked: (0, utils_1.asBigint)(p.totalStaked),
60
60
  totalClaimed: (0, utils_1.asBigint)(p.totalClaimed),
61
+ totalStakedAllTime: p.totalStakedAllTime != null ? (0, utils_1.asBigint)(p.totalStakedAllTime) : undefined,
62
+ totalRewardsAddedAllTime: p.totalRewardsAddedAllTime != null ? (0, utils_1.asBigint)(p.totalRewardsAddedAllTime) : undefined,
61
63
  updatedBlockNumber: p.updatedBlockNumber ? (0, utils_1.asBigint)(p.updatedBlockNumber) : null,
62
64
  updatedBlockTimestamp: p.updatedBlockTimestamp
63
65
  ? (0, utils_1.asBigint)(p.updatedBlockTimestamp)
@@ -89,6 +91,8 @@ class AintiVirusEVMSubgraph {
89
91
  withdrawalCount: (0, utils_1.asBigint)(p.withdrawalCount),
90
92
  totalStaked: (0, utils_1.asBigint)(p.totalStaked),
91
93
  totalClaimed: (0, utils_1.asBigint)(p.totalClaimed),
94
+ totalStakedAllTime: p.totalStakedAllTime != null ? (0, utils_1.asBigint)(p.totalStakedAllTime) : undefined,
95
+ totalRewardsAddedAllTime: p.totalRewardsAddedAllTime != null ? (0, utils_1.asBigint)(p.totalRewardsAddedAllTime) : undefined,
92
96
  updatedBlockNumber: p.updatedBlockNumber ? (0, utils_1.asBigint)(p.updatedBlockNumber) : null,
93
97
  updatedBlockTimestamp: p.updatedBlockTimestamp
94
98
  ? (0, utils_1.asBigint)(p.updatedBlockTimestamp)
@@ -218,6 +222,8 @@ class AintiVirusEVMSubgraph {
218
222
  start: (0, utils_1.asBigint)(s.start),
219
223
  end: (0, utils_1.asBigint)(s.end),
220
224
  duration: (0, utils_1.asBigint)(s.duration),
225
+ totalStaked: s.totalStaked != null ? (0, utils_1.asBigint)(s.totalStaked) : undefined,
226
+ totalReward: s.totalReward != null ? (0, utils_1.asBigint)(s.totalReward) : undefined,
221
227
  assets: (s.assets ?? []).map((a) => ({
222
228
  id: a.id,
223
229
  asset: typeof a.asset === "string" ? a.asset : String(a.asset),
@@ -228,6 +234,51 @@ class AintiVirusEVMSubgraph {
228
234
  })),
229
235
  };
230
236
  }
237
+ /**
238
+ * Get all seasons with TVL and rewards.
239
+ */
240
+ async getAllSeasons() {
241
+ const data = await this.request(queries_1.QUERIES.allSeasons);
242
+ return (data.seasons ?? []).map((s) => ({
243
+ id: s.id,
244
+ seasonId: (0, utils_1.asBigint)(s.seasonId),
245
+ totalStaked: (0, utils_1.asBigint)(s.totalStaked ?? 0),
246
+ totalReward: (0, utils_1.asBigint)(s.totalReward ?? 0),
247
+ start: (0, utils_1.asBigint)(s.start ?? 0),
248
+ end: (0, utils_1.asBigint)(s.end ?? 0),
249
+ }));
250
+ }
251
+ /**
252
+ * Get season with participants (staker addresses and staked amounts).
253
+ */
254
+ async getSeasonWithParticipants(seasonId) {
255
+ const id = seasonId.toString();
256
+ const data = await this.request(queries_1.QUERIES.seasonWithParticipants, {
257
+ seasonId: id,
258
+ });
259
+ const s = data.season;
260
+ if (!s)
261
+ return null;
262
+ return {
263
+ id: s.id,
264
+ seasonId: (0, utils_1.asBigint)(s.seasonId),
265
+ start: (0, utils_1.asBigint)(s.start),
266
+ end: (0, utils_1.asBigint)(s.end),
267
+ duration: 0n,
268
+ totalStaked: s.totalStaked != null ? (0, utils_1.asBigint)(s.totalStaked) : 0n,
269
+ totalReward: s.totalReward != null ? (0, utils_1.asBigint)(s.totalReward) : 0n,
270
+ participants: (s.participants ?? []).map((p) => ({
271
+ staker: typeof p.staker === "string" ? p.staker : String(p.staker),
272
+ totalStaked: (0, utils_1.asBigint)(p.totalStaked ?? 0),
273
+ })),
274
+ };
275
+ }
276
+ /**
277
+ * Get protocol lifetime stats (id = "protocol").
278
+ */
279
+ async getProtocolLifetimeStats() {
280
+ return this.getProtocol("protocol");
281
+ }
231
282
  async getSeasonAssets(params) {
232
283
  const { seasonId, asset, first = 50, skip = 0, orderDirection = "desc", } = params ?? {};
233
284
  const where = {};
@@ -1,11 +1,14 @@
1
1
  export declare const QUERIES: {
2
- readonly protocol: "\n query GetProtocol($id: ID!) {\n protocol(id: $id) {\n id\n feeRate\n factoryAddress\n stakingAddress\n feeCollector\n rewardPoolShareBps\n nextSeasonDuration\n currentSeasonId\n totalDeposited\n totalWithdrawn\n depositCount\n withdrawalCount\n totalStaked\n totalClaimed\n updatedBlockNumber\n updatedBlockTimestamp\n updatedTransactionHash\n }\n }\n ";
3
- readonly protocolData: "\n query GetProtocolData {\n protocols(first: 1, orderBy: updatedBlockTimestamp, orderDirection: desc) {\n id\n feeRate\n factoryAddress\n stakingAddress\n feeCollector\n rewardPoolShareBps\n nextSeasonDuration\n currentSeasonId\n totalDeposited\n totalWithdrawn\n depositCount\n withdrawalCount\n totalStaked\n totalClaimed\n updatedBlockNumber\n updatedBlockTimestamp\n updatedTransactionHash\n }\n }\n ";
2
+ readonly protocol: "\n query GetProtocol($id: ID!) {\n protocol(id: $id) {\n id\n feeRate\n factoryAddress\n stakingAddress\n feeCollector\n rewardPoolShareBps\n nextSeasonDuration\n currentSeasonId\n totalDeposited\n totalWithdrawn\n depositCount\n withdrawalCount\n totalStaked\n totalClaimed\n totalStakedAllTime\n totalRewardsAddedAllTime\n updatedBlockNumber\n updatedBlockTimestamp\n updatedTransactionHash\n }\n }\n ";
3
+ readonly protocolData: "\n query GetProtocolData {\n protocols(first: 1, orderBy: updatedBlockTimestamp, orderDirection: desc) {\n id\n feeRate\n factoryAddress\n stakingAddress\n feeCollector\n rewardPoolShareBps\n nextSeasonDuration\n currentSeasonId\n totalDeposited\n totalWithdrawn\n depositCount\n withdrawalCount\n totalStaked\n totalClaimed\n totalStakedAllTime\n totalRewardsAddedAllTime\n updatedBlockNumber\n updatedBlockTimestamp\n updatedTransactionHash\n }\n }\n ";
4
4
  readonly mixerPools: "\n query GetMixerPools(\n $first: Int!,\n $skip: Int!,\n $where: MixerPool_filter,\n $orderBy: MixerPool_orderBy!,\n $orderDirection: OrderDirection!\n ) {\n mixerPools(\n first: $first,\n skip: $skip,\n where: $where,\n orderBy: $orderBy,\n orderDirection: $orderDirection\n ) {\n id\n asset\n amount\n address\n deployedBlockNumber\n deployedBlockTimestamp\n deployedTransactionHash\n totalDeposited\n totalWithdrawn\n depositCount\n withdrawalCount\n }\n }\n ";
5
5
  readonly mixerPoolById: "\n query GetMixerPool($id: ID!) {\n mixerPool(id: $id) {\n id\n asset\n amount\n address\n deployedBlockNumber\n deployedBlockTimestamp\n deployedTransactionHash\n totalDeposited\n totalWithdrawn\n depositCount\n withdrawalCount\n }\n }\n ";
6
6
  readonly deposits: "\n query GetDeposits(\n $first: Int!,\n $skip: Int!,\n $where: Deposit_filter,\n $orderBy: Deposit_orderBy!,\n $orderDirection: OrderDirection!\n ) {\n deposits(\n first: $first,\n skip: $skip,\n where: $where,\n orderBy: $orderBy,\n orderDirection: $orderDirection\n ) {\n id\n pool { id }\n commitment\n protocolFee\n extraFee\n partnerAddress\n blockNumber\n blockTimestamp\n transactionHash\n }\n }\n ";
7
7
  readonly withdrawals: "\n query GetWithdrawals(\n $first: Int!,\n $skip: Int!,\n $where: Withdrawal_filter,\n $orderBy: Withdrawal_orderBy!,\n $orderDirection: OrderDirection!\n ) {\n withdrawals(\n first: $first,\n skip: $skip,\n where: $where,\n orderBy: $orderBy,\n orderDirection: $orderDirection\n ) {\n id\n pool { id }\n to\n nullifierHash\n blockNumber\n blockTimestamp\n transactionHash\n }\n }\n ";
8
- readonly season: "\n query GetSeason($id: ID!) {\n season(id: $id) {\n id\n seasonId\n start\n end\n duration\n assets {\n id\n asset\n duration\n totalStaked\n totalReward\n totalWeight\n }\n }\n }\n ";
8
+ readonly season: "\n query GetSeason($id: ID!) {\n season(id: $id) {\n id\n seasonId\n start\n end\n duration\n totalStaked\n totalReward\n assets {\n id\n asset\n duration\n totalStaked\n totalReward\n totalWeight\n }\n }\n }\n ";
9
+ readonly seasonWithParticipants: "\n query GetSeasonParticipants($seasonId: ID!) {\n season(id: $seasonId) {\n id\n seasonId\n totalStaked\n totalReward\n start\n end\n participants {\n staker\n totalStaked\n }\n }\n }\n ";
10
+ readonly allSeasons: "\n query GetAllSeasons {\n seasons(first: 100, orderBy: seasonId, orderDirection: desc) {\n id\n seasonId\n totalStaked\n totalReward\n start\n end\n }\n }\n ";
11
+ readonly seasonByAsset: "\n query GetSeasonByAsset($seasonId: ID!) {\n season(id: $seasonId) {\n id\n seasonId\n totalStaked\n totalReward\n assets {\n asset\n totalStaked\n totalReward\n }\n }\n }\n ";
9
12
  readonly seasonAssets: "\n query GetSeasonAssets(\n $first: Int!,\n $skip: Int!,\n $where: SeasonAsset_filter,\n $orderDirection: OrderDirection!\n ) {\n seasonAssets(\n first: $first,\n skip: $skip,\n where: $where,\n orderBy: id,\n orderDirection: $orderDirection\n ) {\n id\n asset\n duration\n totalStaked\n totalReward\n totalWeight\n }\n }\n ";
10
13
  readonly stakedEvents: "\n query GetStakedEvents(\n $first: Int!,\n $skip: Int!,\n $where: Staked_filter,\n $orderDirection: OrderDirection!\n ) {\n stakeds(\n first: $first,\n skip: $skip,\n where: $where,\n orderBy: blockTimestamp,\n orderDirection: $orderDirection\n ) {\n id\n staker\n seasonAsset { id }\n amount\n blockNumber\n blockTimestamp\n transactionHash\n }\n }\n ";
11
14
  readonly unstakedEvents: "\n query GetUnstakedEvents(\n $first: Int!,\n $skip: Int!,\n $where: Unstaked_filter,\n $orderDirection: OrderDirection!\n ) {\n unstakeds(\n first: $first,\n skip: $skip,\n where: $where,\n orderBy: blockTimestamp,\n orderDirection: $orderDirection\n ) {\n id\n staker\n seasonAsset { id }\n amount\n blockNumber\n blockTimestamp\n transactionHash\n }\n }\n ";
@@ -19,6 +19,8 @@ exports.QUERIES = {
19
19
  withdrawalCount
20
20
  totalStaked
21
21
  totalClaimed
22
+ totalStakedAllTime
23
+ totalRewardsAddedAllTime
22
24
  updatedBlockNumber
23
25
  updatedBlockTimestamp
24
26
  updatedTransactionHash
@@ -42,6 +44,8 @@ exports.QUERIES = {
42
44
  withdrawalCount
43
45
  totalStaked
44
46
  totalClaimed
47
+ totalStakedAllTime
48
+ totalRewardsAddedAllTime
45
49
  updatedBlockNumber
46
50
  updatedBlockTimestamp
47
51
  updatedTransactionHash
@@ -154,6 +158,8 @@ exports.QUERIES = {
154
158
  start
155
159
  end
156
160
  duration
161
+ totalStaked
162
+ totalReward
157
163
  assets {
158
164
  id
159
165
  asset
@@ -164,6 +170,49 @@ exports.QUERIES = {
164
170
  }
165
171
  }
166
172
  }
173
+ `,
174
+ seasonWithParticipants: `
175
+ query GetSeasonParticipants($seasonId: ID!) {
176
+ season(id: $seasonId) {
177
+ id
178
+ seasonId
179
+ totalStaked
180
+ totalReward
181
+ start
182
+ end
183
+ participants {
184
+ staker
185
+ totalStaked
186
+ }
187
+ }
188
+ }
189
+ `,
190
+ allSeasons: `
191
+ query GetAllSeasons {
192
+ seasons(first: 100, orderBy: seasonId, orderDirection: desc) {
193
+ id
194
+ seasonId
195
+ totalStaked
196
+ totalReward
197
+ start
198
+ end
199
+ }
200
+ }
201
+ `,
202
+ seasonByAsset: `
203
+ query GetSeasonByAsset($seasonId: ID!) {
204
+ season(id: $seasonId) {
205
+ id
206
+ seasonId
207
+ totalStaked
208
+ totalReward
209
+ assets {
210
+ asset
211
+ totalStaked
212
+ totalReward
213
+ }
214
+ }
215
+ }
167
216
  `,
168
217
  seasonAssets: `
169
218
  query GetSeasonAssets(
@@ -30,6 +30,10 @@ export interface ProtocolState {
30
30
  withdrawalCount: bigint;
31
31
  totalStaked: bigint;
32
32
  totalClaimed: bigint;
33
+ /** Cumulative staked amount across all seasons */
34
+ totalStakedAllTime?: bigint;
35
+ /** Cumulative rewards added across all seasons */
36
+ totalRewardsAddedAllTime?: bigint;
33
37
  updatedBlockNumber?: bigint | null;
34
38
  updatedBlockTimestamp?: bigint | null;
35
39
  updatedTransactionHash?: string | null;
@@ -119,8 +123,30 @@ export interface SeasonEntity {
119
123
  start: bigint;
120
124
  end: bigint;
121
125
  duration: bigint;
126
+ /** TVL for the season (sum across assets) */
127
+ totalStaked?: bigint;
128
+ /** Total rewards for the season */
129
+ totalReward?: bigint;
122
130
  assets: SeasonAssetEntity[];
123
131
  }
132
+ /** Per-staker participation in a season */
133
+ export interface StakerSeasonParticipant {
134
+ staker: string;
135
+ totalStaked: bigint;
136
+ }
137
+ /** Season with participants list (from participants relation) */
138
+ export interface SeasonWithParticipants extends Omit<SeasonEntity, "assets"> {
139
+ participants: StakerSeasonParticipant[];
140
+ }
141
+ /** Season summary for list views */
142
+ export interface SeasonSummary {
143
+ id: string;
144
+ seasonId: bigint;
145
+ totalStaked: bigint;
146
+ totalReward: bigint;
147
+ start: bigint;
148
+ end: bigint;
149
+ }
124
150
  export interface PaymentStats {
125
151
  id: string;
126
152
  contractAddress: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aintivirus-ai/mixer-sdk",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "TypeScript SDK for AintiVirus Mixer - Easy web3 integration for privacy-preserving transactions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",