@aintivirus-ai/mixer-sdk 1.0.8 → 1.0.9

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.
@@ -96,29 +96,54 @@ export declare class AintiVirusEVM {
96
96
  * Withdraw via relayer (fee from proof).
97
97
  */
98
98
  withdrawRelayed(proof: WithdrawalProof, amount: bigint, assetAddress: string): Promise<TransactionResult>;
99
+ /**
100
+ * Stake any asset deployed as a mixer pool.
101
+ * For WETH with gateway configured: uses native ETH (msg.value).
102
+ * For ERC20: approves factory and calls factory.stake(asset, amount).
103
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
104
+ * @param amount Amount in asset's smallest unit
105
+ */
106
+ stake(assetAddress: string, amount: bigint): Promise<TransactionResult>;
107
+ /**
108
+ * Unstake any asset.
109
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
110
+ */
111
+ unstake(assetAddress: string): Promise<TransactionResult>;
112
+ /**
113
+ * Claim rewards for any asset and season.
114
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
115
+ * @param seasonId Season ID to claim
116
+ */
117
+ claim(assetAddress: string, seasonId: bigint): Promise<TransactionResult>;
99
118
  /**
100
119
  * Stake native ETH via WETHGateway. Requires wethGatewayAddress in config.
101
- * Falls back to stakeToken (config token) if no gateway.
120
+ * Falls back to stake(config token) if no gateway.
121
+ * @deprecated Use stake(wethAddress, amount) instead.
102
122
  */
103
123
  stakeEther(amount: bigint): Promise<TransactionResult>;
104
124
  /**
105
- * Stake tokens
125
+ * Stake config token.
126
+ * @deprecated Use stake(tokenAddress, amount) instead.
106
127
  */
107
128
  stakeToken(amount: bigint): Promise<TransactionResult>;
108
129
  /**
109
- * Claim ETH rewards (WETH asset)
130
+ * Claim ETH rewards (WETH asset).
131
+ * @deprecated Use claim(wethAddress, seasonId) instead.
110
132
  */
111
133
  claimEth(seasonId: bigint): Promise<TransactionResult>;
112
134
  /**
113
- * Claim token rewards
135
+ * Claim config token rewards.
136
+ * @deprecated Use claim(tokenAddress, seasonId) instead.
114
137
  */
115
138
  claimToken(seasonId: bigint): Promise<TransactionResult>;
116
139
  /**
117
- * Unstake ETH (WETH asset)
140
+ * Unstake ETH (WETH asset).
141
+ * @deprecated Use unstake(wethAddress) instead.
118
142
  */
119
143
  unstakeEth(): Promise<TransactionResult>;
120
144
  /**
121
- * Unstake tokens
145
+ * Unstake config token.
146
+ * @deprecated Use unstake(tokenAddress) instead.
122
147
  */
123
148
  unstakeToken(): Promise<TransactionResult>;
124
149
  /**
@@ -276,11 +301,45 @@ export declare class AintiVirusEVM {
276
301
  */
277
302
  getStakerRecord(address: string): Promise<EVMStakerRecord>;
278
303
  /**
279
- * Check if user has claimed rewards for a season
304
+ * Check if user has claimed rewards for a season and asset.
305
+ * @param address Staker address
306
+ * @param seasonId Season ID
307
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
308
+ */
309
+ hasClaimed(address: string, seasonId: bigint, assetAddress: string): Promise<boolean>;
310
+ /**
311
+ * Get staker record for a specific asset.
312
+ * @param address Staker address
313
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
314
+ */
315
+ getStakerRecordForAsset(address: string, assetAddress: string): Promise<{
316
+ seasonId: bigint;
317
+ stakedAt: bigint;
318
+ staked: bigint;
319
+ weight: bigint;
320
+ }>;
321
+ /**
322
+ * Get stake season totals for a specific asset.
323
+ * @param seasonId Season ID
324
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
325
+ */
326
+ getStakeSeasonForAsset(seasonId: bigint, assetAddress: string): Promise<{
327
+ seasonId: bigint;
328
+ start: bigint;
329
+ end: bigint;
330
+ duration: bigint;
331
+ totalStaked: bigint;
332
+ totalReward: bigint;
333
+ totalWeight: bigint;
334
+ }>;
335
+ /**
336
+ * Check if user has claimed ETH rewards for a season.
337
+ * @deprecated Use hasClaimed(address, seasonId, wethAddress) instead.
280
338
  */
281
339
  hasClaimedEth(address: string, seasonId: bigint): Promise<boolean>;
282
340
  /**
283
- * Check if user has claimed token rewards for a season
341
+ * Check if user has claimed token rewards for a season.
342
+ * @deprecated Use hasClaimed(address, seasonId, tokenAddress) instead.
284
343
  */
285
344
  hasClaimedToken(address: string, seasonId: bigint): Promise<boolean>;
286
345
  /**
package/dist/evm/index.js CHANGED
@@ -299,72 +299,116 @@ class AintiVirusEVM {
299
299
  return this.withdraw(proof, fee, amount, assetAddress);
300
300
  }
301
301
  /**
302
- * Stake native ETH via WETHGateway. Requires wethGatewayAddress in config.
303
- * Falls back to stakeToken (config token) if no gateway.
302
+ * Stake any asset deployed as a mixer pool.
303
+ * For WETH with gateway configured: uses native ETH (msg.value).
304
+ * For ERC20: approves factory and calls factory.stake(asset, amount).
305
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
306
+ * @param amount Amount in asset's smallest unit
304
307
  */
305
- async stakeEther(amount) {
308
+ async stake(assetAddress, amount) {
306
309
  this.assertSigner();
307
- if (this.wethGateway) {
308
- const tx = await this.wethGateway.stake({ value: amount });
310
+ const asset = assetAddress.toLowerCase().startsWith("0x")
311
+ ? assetAddress
312
+ : assetAddress;
313
+ const gateway = this.wethGateway;
314
+ const isWeth = gateway && (await this.isWethAsset(asset));
315
+ if (isWeth && gateway) {
316
+ const tx = await gateway.stake({ value: amount });
309
317
  return this.sendAndWait(tx);
310
318
  }
311
- return this.stakeToken(amount);
312
- }
313
- /**
314
- * Stake tokens
315
- */
316
- async stakeToken(amount) {
317
- this.assertSigner();
318
319
  const factoryAddress = await this.factory.getAddress();
319
- const allowance = await this.token.allowance(await this.signer.getAddress(), factoryAddress);
320
+ const assetContract = asset.toLowerCase() === this.token.target.toLowerCase()
321
+ ? this.token
322
+ : new ethers_1.Contract(asset, ERC20_ABI, this.signer);
323
+ const allowanceRaw = await assetContract.allowance(await this.signer.getAddress(), factoryAddress);
324
+ const allowance = toBigint(allowanceRaw);
320
325
  if (allowance < amount) {
321
- const approveTx = await this.token.approve(factoryAddress, amount);
326
+ const approveTx = await assetContract.approve(factoryAddress, amount);
322
327
  const approveHash = typeof approveTx.hash === "string"
323
328
  ? approveTx.hash
324
329
  : approveTx.hash;
325
330
  if (approveHash)
326
- await this.sendAndWait(approveTx);
331
+ await this.waitForTransactionReceipt(approveHash);
327
332
  }
328
- const tx = await this.factory.stake(this.token.target, amount);
333
+ const tx = await this.factory.stake(asset, amount);
329
334
  return this.sendAndWait(tx);
330
335
  }
331
336
  /**
332
- * Claim ETH rewards (WETH asset)
337
+ * Unstake any asset.
338
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
333
339
  */
334
- async claimEth(seasonId) {
340
+ async unstake(assetAddress) {
335
341
  this.assertSigner();
342
+ const asset = assetAddress.toLowerCase().startsWith("0x")
343
+ ? assetAddress
344
+ : assetAddress;
345
+ const tx = await this.factory.unstake(asset);
346
+ return this.sendAndWait(tx);
347
+ }
348
+ /**
349
+ * Claim rewards for any asset and season.
350
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
351
+ * @param seasonId Season ID to claim
352
+ */
353
+ async claim(assetAddress, seasonId) {
354
+ this.assertSigner();
355
+ const asset = assetAddress.toLowerCase().startsWith("0x")
356
+ ? assetAddress
357
+ : assetAddress;
358
+ const tx = await this.factory.claim(asset, seasonId);
359
+ return this.sendAndWait(tx);
360
+ }
361
+ /**
362
+ * Stake native ETH via WETHGateway. Requires wethGatewayAddress in config.
363
+ * Falls back to stake(config token) if no gateway.
364
+ * @deprecated Use stake(wethAddress, amount) instead.
365
+ */
366
+ async stakeEther(amount) {
367
+ const weth = await this.getWethAddress();
368
+ if (weth)
369
+ return this.stake(weth, amount);
370
+ return this.stake(this.token.target, amount);
371
+ }
372
+ /**
373
+ * Stake config token.
374
+ * @deprecated Use stake(tokenAddress, amount) instead.
375
+ */
376
+ async stakeToken(amount) {
377
+ return this.stake(this.token.target, amount);
378
+ }
379
+ /**
380
+ * Claim ETH rewards (WETH asset).
381
+ * @deprecated Use claim(wethAddress, seasonId) instead.
382
+ */
383
+ async claimEth(seasonId) {
336
384
  const weth = await this.getWethAddress();
337
385
  if (!weth)
338
386
  throw new Error("WETH address not available (config or factory.weth())");
339
- const tx = await this.factory.claim(weth, seasonId);
340
- return this.sendAndWait(tx);
387
+ return this.claim(weth, seasonId);
341
388
  }
342
389
  /**
343
- * Claim token rewards
390
+ * Claim config token rewards.
391
+ * @deprecated Use claim(tokenAddress, seasonId) instead.
344
392
  */
345
393
  async claimToken(seasonId) {
346
- this.assertSigner();
347
- const tx = await this.factory.claim(this.token.target, seasonId);
348
- return this.sendAndWait(tx);
394
+ return this.claim(this.token.target, seasonId);
349
395
  }
350
396
  /**
351
- * Unstake ETH (WETH asset)
397
+ * Unstake ETH (WETH asset).
398
+ * @deprecated Use unstake(wethAddress) instead.
352
399
  */
353
400
  async unstakeEth() {
354
- this.assertSigner();
355
401
  const weth = await this.getWethAddress();
356
402
  if (!weth)
357
403
  throw new Error("WETH address not available (config or factory.weth())");
358
- const tx = await this.factory.unstake(weth);
359
- return this.sendAndWait(tx);
404
+ return this.unstake(weth);
360
405
  }
361
406
  /**
362
- * Unstake tokens
407
+ * Unstake config token.
408
+ * @deprecated Use unstake(tokenAddress) instead.
363
409
  */
364
410
  async unstakeToken() {
365
- this.assertSigner();
366
- const tx = await this.factory.unstake(this.token.target);
367
- return this.sendAndWait(tx);
411
+ return this.unstake(this.token.target);
368
412
  }
369
413
  /**
370
414
  * Get current stake season
@@ -722,22 +766,75 @@ class AintiVirusEVM {
722
766
  };
723
767
  }
724
768
  /**
725
- * Check if user has claimed rewards for a season
769
+ * Check if user has claimed rewards for a season and asset.
770
+ * @param address Staker address
771
+ * @param seasonId Season ID
772
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
726
773
  */
727
- async hasClaimedEth(address, seasonId) {
774
+ async hasClaimed(address, seasonId, assetAddress) {
775
+ const stakingAddress = await this.getStakingAddress();
776
+ const staking = new ethers_1.Contract(stakingAddress, STAKING_ABI, this.provider);
777
+ const asset = assetAddress.toLowerCase().startsWith("0x")
778
+ ? assetAddress
779
+ : assetAddress;
780
+ return await staking.wasSeasonClaimed(address, seasonId, asset);
781
+ }
782
+ /**
783
+ * Get staker record for a specific asset.
784
+ * @param address Staker address
785
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
786
+ */
787
+ async getStakerRecordForAsset(address, assetAddress) {
788
+ const stakingAddress = await this.getStakingAddress();
789
+ const staking = new ethers_1.Contract(stakingAddress, STAKING_ABI, this.provider);
790
+ const asset = assetAddress.toLowerCase().startsWith("0x")
791
+ ? assetAddress
792
+ : assetAddress;
793
+ const r = await staking.records(address, asset);
794
+ return {
795
+ seasonId: BigInt(r.seasonId.toString()),
796
+ stakedAt: BigInt(r.stakedAt.toString()),
797
+ staked: BigInt(r.staked.toString()),
798
+ weight: BigInt(r.weight.toString()),
799
+ };
800
+ }
801
+ /**
802
+ * Get stake season totals for a specific asset.
803
+ * @param seasonId Season ID
804
+ * @param assetAddress Asset address (WETH or any ERC20 deployed as mixer)
805
+ */
806
+ async getStakeSeasonForAsset(seasonId, assetAddress) {
728
807
  const stakingAddress = await this.getStakingAddress();
729
808
  const staking = new ethers_1.Contract(stakingAddress, STAKING_ABI, this.provider);
809
+ const asset = assetAddress.toLowerCase().startsWith("0x")
810
+ ? assetAddress
811
+ : assetAddress;
812
+ const s = await staking.seasonAndTotals(seasonId, asset);
813
+ return {
814
+ seasonId: BigInt(s.seasonId.toString()),
815
+ start: BigInt(s.start.toString()),
816
+ end: BigInt(s.end.toString()),
817
+ duration: BigInt(s.duration.toString()),
818
+ totalStaked: BigInt(s.totalStaked.toString()),
819
+ totalReward: BigInt(s.totalReward.toString()),
820
+ totalWeight: BigInt(s.totalWeight.toString()),
821
+ };
822
+ }
823
+ /**
824
+ * Check if user has claimed ETH rewards for a season.
825
+ * @deprecated Use hasClaimed(address, seasonId, wethAddress) instead.
826
+ */
827
+ async hasClaimedEth(address, seasonId) {
730
828
  const weth = await this.getWethAddress();
731
829
  const ethAsset = weth ?? this.token.target;
732
- return await staking.wasSeasonClaimed(address, seasonId, ethAsset);
830
+ return this.hasClaimed(address, seasonId, ethAsset);
733
831
  }
734
832
  /**
735
- * Check if user has claimed token rewards for a season
833
+ * Check if user has claimed token rewards for a season.
834
+ * @deprecated Use hasClaimed(address, seasonId, tokenAddress) instead.
736
835
  */
737
836
  async hasClaimedToken(address, seasonId) {
738
- const stakingAddress = await this.getStakingAddress();
739
- const staking = new ethers_1.Contract(stakingAddress, STAKING_ABI, this.provider);
740
- return await staking.wasSeasonClaimed(address, seasonId, this.token.target);
837
+ return this.hasClaimed(address, seasonId, this.token.target);
741
838
  }
742
839
  /**
743
840
  * Get token balance of an address
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aintivirus-ai/mixer-sdk",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
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",