@wireio/stake 2.4.3 → 2.5.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/stake.browser.js +55 -48
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +14 -9
- package/lib/stake.js +63 -55
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +55 -48
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/networks/ethereum/ethereum.ts +2 -2
- package/src/networks/solana/clients/convert.client.ts +5 -3
- package/src/networks/solana/clients/outpost.client.ts +33 -44
- package/src/networks/solana/solana.ts +12 -2
- package/src/networks/solana/types.ts +10 -6
- package/src/networks/solana/utils.ts +8 -0
- package/src/types.ts +1 -1
package/lib/stake.browser.js
CHANGED
|
@@ -15839,6 +15839,14 @@ function normalizeToBigInt(x) {
|
|
|
15839
15839
|
if (typeof x === "number") return BigInt(x);
|
|
15840
15840
|
throw new Error(`normalizeToBigInt: unsupported type ${typeof x}`);
|
|
15841
15841
|
}
|
|
15842
|
+
const safeFetch = async (promise, label) => {
|
|
15843
|
+
try {
|
|
15844
|
+
return await promise;
|
|
15845
|
+
} catch (err) {
|
|
15846
|
+
console.error(`Safe Fetch Failed${label ? ` (${label})` : ""}:`, err);
|
|
15847
|
+
return null;
|
|
15848
|
+
}
|
|
15849
|
+
};
|
|
15842
15850
|
|
|
15843
15851
|
let ConvertClient$1 = class ConvertClient {
|
|
15844
15852
|
constructor(provider, pgs) {
|
|
@@ -16062,10 +16070,12 @@ let ConvertClient$1 = class ConvertClient {
|
|
|
16062
16070
|
}
|
|
16063
16071
|
let slotTimeSec = 0.4;
|
|
16064
16072
|
try {
|
|
16065
|
-
const samples = await conn.getRecentPerformanceSamples(
|
|
16073
|
+
const samples = await conn.getRecentPerformanceSamples(60);
|
|
16066
16074
|
if (samples?.length) {
|
|
16067
|
-
const
|
|
16068
|
-
|
|
16075
|
+
const valid = samples.filter((s) => s.numSlots > 0);
|
|
16076
|
+
if (valid.length) {
|
|
16077
|
+
slotTimeSec = valid.reduce((sum, s) => sum + s.samplePeriodSecs / s.numSlots, 0) / valid.length;
|
|
16078
|
+
}
|
|
16069
16079
|
}
|
|
16070
16080
|
} catch (_) {
|
|
16071
16081
|
}
|
|
@@ -16367,50 +16377,39 @@ class OutpostClient {
|
|
|
16367
16377
|
return buildOutpostAccounts(this.connection, userPk, this.pgs);
|
|
16368
16378
|
}
|
|
16369
16379
|
async getTokenBalance(ata) {
|
|
16370
|
-
|
|
16371
|
-
|
|
16372
|
-
return new BN(bal.value.amount);
|
|
16373
|
-
} catch {
|
|
16374
|
-
return new BN(0);
|
|
16375
|
-
}
|
|
16380
|
+
const bal = await this.connection.getTokenAccountBalance(ata);
|
|
16381
|
+
return new BN(bal.value.amount);
|
|
16376
16382
|
}
|
|
16377
16383
|
async fetchWireState(user) {
|
|
16378
16384
|
const userPk = user ?? this.wallet.publicKey;
|
|
16379
|
-
if (!userPk)
|
|
16380
|
-
throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16381
|
-
}
|
|
16385
|
+
if (!userPk) throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16382
16386
|
const pdas = await this.buildAccounts(userPk);
|
|
16383
|
-
|
|
16384
|
-
|
|
16385
|
-
|
|
16386
|
-
|
|
16387
|
-
|
|
16388
|
-
|
|
16389
|
-
|
|
16390
|
-
|
|
16391
|
-
|
|
16392
|
-
|
|
16393
|
-
|
|
16394
|
-
|
|
16395
|
-
|
|
16396
|
-
|
|
16397
|
-
|
|
16398
|
-
|
|
16399
|
-
|
|
16400
|
-
|
|
16401
|
-
|
|
16402
|
-
|
|
16403
|
-
|
|
16404
|
-
|
|
16405
|
-
|
|
16406
|
-
|
|
16407
|
-
|
|
16408
|
-
|
|
16409
|
-
};
|
|
16410
|
-
} catch (err) {
|
|
16411
|
-
console.error("Error fetching Outpost wire state:", err);
|
|
16412
|
-
throw err;
|
|
16413
|
-
}
|
|
16387
|
+
const [
|
|
16388
|
+
globalState,
|
|
16389
|
+
outpostAccount,
|
|
16390
|
+
distributionState,
|
|
16391
|
+
userPretokenRecord,
|
|
16392
|
+
trancheState,
|
|
16393
|
+
liqsolPoolBalance,
|
|
16394
|
+
userLiqsolBalance
|
|
16395
|
+
] = await Promise.all([
|
|
16396
|
+
safeFetch(this.program.account.globalState.fetch(pdas.globalState), "globalState"),
|
|
16397
|
+
safeFetch(this.program.account.outpostAccount.fetchNullable(pdas.outpostAccount), "outpostAccount"),
|
|
16398
|
+
safeFetch(this.program.account.distributionState.fetchNullable(pdas.distributionState), "distributionState"),
|
|
16399
|
+
safeFetch(this.program.account.userPretokenRecord.fetchNullable(pdas.userPretokenRecord), "userPretokenRecord"),
|
|
16400
|
+
safeFetch(this.program.account.trancheState.fetchNullable(pdas.trancheState), "trancheState"),
|
|
16401
|
+
safeFetch(this.getTokenBalance(pdas.liqsolPoolAta), "liqsolPoolAta"),
|
|
16402
|
+
safeFetch(this.getTokenBalance(pdas.userAta), "userAta")
|
|
16403
|
+
]);
|
|
16404
|
+
return {
|
|
16405
|
+
globalState,
|
|
16406
|
+
outpostAccount,
|
|
16407
|
+
distributionState,
|
|
16408
|
+
trancheState,
|
|
16409
|
+
userPretokenRecord,
|
|
16410
|
+
liqsolPoolBalance,
|
|
16411
|
+
userLiqsolBalance
|
|
16412
|
+
};
|
|
16414
16413
|
}
|
|
16415
16414
|
async buildStakeIx(amountLamports, user = this.wallet.publicKey) {
|
|
16416
16415
|
if (!user) {
|
|
@@ -17051,9 +17050,9 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17051
17050
|
throw err;
|
|
17052
17051
|
}
|
|
17053
17052
|
}
|
|
17054
|
-
async getPortfolio() {
|
|
17053
|
+
async getPortfolio(address) {
|
|
17055
17054
|
try {
|
|
17056
|
-
const user = !!this.squadsX ? this.squadsVaultPDA : this.solPubKey;
|
|
17055
|
+
const user = address ? new PublicKey(address) : !!this.squadsX ? this.squadsVaultPDA : this.solPubKey;
|
|
17057
17056
|
const reservePoolPDA = this.program.deriveReservePoolPda();
|
|
17058
17057
|
const vaultPDA = this.program.deriveVaultPda();
|
|
17059
17058
|
const liqsolMint = this.program.deriveLiqsolMintPda();
|
|
@@ -17078,6 +17077,14 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17078
17077
|
const userPretokenRecord = snapshot?.userPretokenRecord ?? null;
|
|
17079
17078
|
const stakedLiqsolStr = outpostAccount?.stakedLiqsol?.toString?.() ?? "0";
|
|
17080
17079
|
const wirePretokensStr = userPretokenRecord?.totalPretokensPurchased?.toString?.() ?? "0";
|
|
17080
|
+
console.log("userPretokenRecord", userPretokenRecord);
|
|
17081
|
+
console.log("address", address);
|
|
17082
|
+
console.log("userPretokenRecord?.totalPretokensPurchased?.toString", userPretokenRecord?.totalPretokensPurchased?.toString);
|
|
17083
|
+
if (userPretokenRecord) {
|
|
17084
|
+
for (const [key, value] of Object.entries(userPretokenRecord)) {
|
|
17085
|
+
console.log(`userPretokenRecord.${key}: ${value?.toString?.() ?? value}`);
|
|
17086
|
+
}
|
|
17087
|
+
}
|
|
17081
17088
|
const currentIndexStr = globalState?.currentIndex?.toString?.() ?? "0";
|
|
17082
17089
|
const totalSharesStr = globalState?.totalShares?.toString?.() ?? "0";
|
|
17083
17090
|
const userSharesStr = outpostAccount?.stakedShares?.toString?.() ?? "0";
|
|
@@ -42738,10 +42745,10 @@ class EthereumStakingClient {
|
|
|
42738
42745
|
let result = await this.validatorClient.validatorDepositAndLockBond();
|
|
42739
42746
|
return result && result.txHash ? result.txHash : "Error - no resulting txHash";
|
|
42740
42747
|
}
|
|
42741
|
-
async getPortfolio() {
|
|
42748
|
+
async getPortfolio(address) {
|
|
42742
42749
|
try {
|
|
42743
42750
|
if (!this.signer) return Promise.resolve(null);
|
|
42744
|
-
const walletAddress = await this.address;
|
|
42751
|
+
const walletAddress = address ?? await this.address;
|
|
42745
42752
|
const nativeBalance = await this.provider.getBalance(walletAddress);
|
|
42746
42753
|
const nativeDecimals = this.network?.nativeCurrency?.decimals ?? 18;
|
|
42747
42754
|
const nativeSymbol = this.network?.nativeCurrency?.symbol ?? "ETH";
|
|
@@ -43002,5 +43009,5 @@ var types = /*#__PURE__*/Object.freeze({
|
|
|
43002
43009
|
__proto__: null
|
|
43003
43010
|
});
|
|
43004
43011
|
|
|
43005
|
-
export { ADDRESSES, ADDRESS_BOOK_BY_CHAIN, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS_BY_CHAIN, ConvertClient$1 as ConvertClient, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, HOODI_ADDRESSES, INDEX_SCALE$1 as INDEX_SCALE, INITIAL_TRANCHE_SUPPLY, LAMPORTS_PER_SOL, LeaderboardClient, MAINNET_ADDRESSES, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS_BY_CHAIN, PurchaseAsset, ReceiptNFTKind, SCALE, types as SOL, SolanaStakingClient, Staker, SupportedEvmChainID, SupportedSolChainID, TokenClient, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, ceilDiv, deriveEphemeralStakeAddress, generateRandomDepositAmount, generateTestKeypair, getEpochSnapshot, getErrorMessage, getProgramIds, lamportsToSol, msToEpochEnd, normalizeToBigInt, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
|
|
43012
|
+
export { ADDRESSES, ADDRESS_BOOK_BY_CHAIN, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS_BY_CHAIN, ConvertClient$1 as ConvertClient, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, HOODI_ADDRESSES, INDEX_SCALE$1 as INDEX_SCALE, INITIAL_TRANCHE_SUPPLY, LAMPORTS_PER_SOL, LeaderboardClient, MAINNET_ADDRESSES, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS_BY_CHAIN, PurchaseAsset, ReceiptNFTKind, SCALE, types as SOL, SolanaStakingClient, Staker, SupportedEvmChainID, SupportedSolChainID, TokenClient, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, ceilDiv, deriveEphemeralStakeAddress, generateRandomDepositAmount, generateTestKeypair, getEpochSnapshot, getErrorMessage, getProgramIds, lamportsToSol, msToEpochEnd, normalizeToBigInt, safeFetch, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
|
|
43006
43013
|
//# sourceMappingURL=stake.browser.js.map
|