@wireio/stake 2.4.3 → 2.4.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wireio/stake",
3
- "version": "2.4.3",
3
+ "version": "2.4.4",
4
4
  "description": "LIQ Staking Module for Wire Network",
5
5
  "homepage": "https://gitea.gitgo.app/Wire/sdk-stake",
6
6
  "license": "FSL-1.1-Apache-2.0",
@@ -202,12 +202,12 @@ export class EthereumStakingClient implements IStakingClient {
202
202
  * actual = liqETH token balance (ERC-20)
203
203
  * tracked = liqETH tracked balance (protocol/accounting view)
204
204
  */
205
- async getPortfolio(): Promise<Portfolio | null> {
205
+ async getPortfolio(address?: string): Promise<Portfolio | null> {
206
206
 
207
207
  try {
208
208
  if (!this.signer) return Promise.resolve(null);
209
209
 
210
- const walletAddress = await this.address!;
210
+ const walletAddress = address ?? await this.address!;
211
211
 
212
212
  // 1) Native ETH balance
213
213
  const nativeBalance = await this.provider.getBalance(walletAddress);
@@ -316,10 +316,12 @@ export class ConvertClient {
316
316
 
317
317
  let slotTimeSec = 0.4;
318
318
  try {
319
- const samples = await conn.getRecentPerformanceSamples(1);
319
+ const samples = await conn.getRecentPerformanceSamples(60);
320
320
  if (samples?.length) {
321
- const s = samples[0];
322
- slotTimeSec = s.numSlots > 0 ? s.samplePeriodSecs / s.numSlots : slotTimeSec;
321
+ const valid = samples.filter(s => s.numSlots > 0);
322
+ if (valid.length) {
323
+ slotTimeSec = valid.reduce((sum, s) => sum + s.samplePeriodSecs / s.numSlots, 0) / valid.length;
324
+ }
323
325
  }
324
326
  } catch (_) {
325
327
  // ignore
@@ -389,10 +389,11 @@ export class SolanaStakingClient implements IStakingClient {
389
389
  * - yield: on-chain index/shares plus an estimated accrued liqSOL yield
390
390
  * - extras: useful internal addresses and raw state for debugging/UX
391
391
  */
392
- async getPortfolio(): Promise<Portfolio> {
392
+ async getPortfolio(address?: string): Promise<Portfolio> {
393
393
  // if (!this.pubKey) throw new Error('User pubKey is undefined');
394
394
  try {
395
- const user = !!this.squadsX ? this.squadsVaultPDA! : this.solPubKey;
395
+ const user = address ? new SolPubKey(address) :
396
+ !!this.squadsX ? this.squadsVaultPDA! : this.solPubKey;
396
397
 
397
398
  const reservePoolPDA = this.program.deriveReservePoolPda();
398
399
  const vaultPDA = this.program.deriveVaultPda();
package/src/types.ts CHANGED
@@ -50,7 +50,7 @@ export interface IStakingClient {
50
50
  getPendingWithdraws(address?: string): Promise<WithdrawReceipt[]>
51
51
 
52
52
  /** Fetch the complete user portfolio */
53
- getPortfolio(): Promise<Portfolio | null>;
53
+ getPortfolio(address?: string): Promise<Portfolio | null>;
54
54
 
55
55
  // Estimated total APY for staking yeild
56
56
  getSystemAPY(): Promise<number>;