@wireio/stake 2.4.4 → 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 +46 -41
- package/lib/stake.browser.js.map +1 -1
- package/lib/stake.d.ts +11 -6
- package/lib/stake.js +54 -48
- package/lib/stake.js.map +1 -1
- package/lib/stake.m.js +46 -41
- package/lib/stake.m.js.map +1 -1
- package/package.json +1 -1
- package/src/networks/solana/clients/outpost.client.ts +33 -44
- package/src/networks/solana/solana.ts +9 -0
- package/src/networks/solana/types.ts +10 -6
- package/src/networks/solana/utils.ts +8 -0
package/lib/stake.m.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) {
|
|
@@ -16369,50 +16377,39 @@ class OutpostClient {
|
|
|
16369
16377
|
return buildOutpostAccounts(this.connection, userPk, this.pgs);
|
|
16370
16378
|
}
|
|
16371
16379
|
async getTokenBalance(ata) {
|
|
16372
|
-
|
|
16373
|
-
|
|
16374
|
-
return new BN(bal.value.amount);
|
|
16375
|
-
} catch {
|
|
16376
|
-
return new BN(0);
|
|
16377
|
-
}
|
|
16380
|
+
const bal = await this.connection.getTokenAccountBalance(ata);
|
|
16381
|
+
return new BN(bal.value.amount);
|
|
16378
16382
|
}
|
|
16379
16383
|
async fetchWireState(user) {
|
|
16380
16384
|
const userPk = user ?? this.wallet.publicKey;
|
|
16381
|
-
if (!userPk)
|
|
16382
|
-
throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16383
|
-
}
|
|
16385
|
+
if (!userPk) throw new Error("OutpostClient.fetchWireState: wallet not connected");
|
|
16384
16386
|
const pdas = await this.buildAccounts(userPk);
|
|
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
|
-
|
|
16411
|
-
};
|
|
16412
|
-
} catch (err) {
|
|
16413
|
-
console.error("Error fetching Outpost wire state:", err);
|
|
16414
|
-
throw err;
|
|
16415
|
-
}
|
|
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
|
+
};
|
|
16416
16413
|
}
|
|
16417
16414
|
async buildStakeIx(amountLamports, user = this.wallet.publicKey) {
|
|
16418
16415
|
if (!user) {
|
|
@@ -17080,6 +17077,14 @@ const _SolanaStakingClient = class _SolanaStakingClient {
|
|
|
17080
17077
|
const userPretokenRecord = snapshot?.userPretokenRecord ?? null;
|
|
17081
17078
|
const stakedLiqsolStr = outpostAccount?.stakedLiqsol?.toString?.() ?? "0";
|
|
17082
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
|
+
}
|
|
17083
17088
|
const currentIndexStr = globalState?.currentIndex?.toString?.() ?? "0";
|
|
17084
17089
|
const totalSharesStr = globalState?.totalShares?.toString?.() ?? "0";
|
|
17085
17090
|
const userSharesStr = outpostAccount?.stakedShares?.toString?.() ?? "0";
|
|
@@ -43004,5 +43009,5 @@ var types = /*#__PURE__*/Object.freeze({
|
|
|
43004
43009
|
__proto__: null
|
|
43005
43010
|
});
|
|
43006
43011
|
|
|
43007
|
-
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 };
|
|
43008
43013
|
//# sourceMappingURL=stake.m.js.map
|